#CCBCHMOT0000010. Phép trừ sai (Wrong Subtraction)
Phép trừ sai (Wrong Subtraction)
Wrong Subtraction
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For a positive integer n, an operation subtracts one if its last decimal digit is nonzero; otherwise it removes the trailing zero by integer division by ten. Apply exactly k operations and print the result. The result is guaranteed positive.
Input
One line contains integers n and k.
Output
Print n after exactly k operations.
Subtasks
- Subtask 1 (20%): 2 <= n <= 100, 1 <= k <= 5; the final result is positive.
- Subtask 2 (30%): 2 <= n <= 1000000, 1 <= k <= 20; the final result is positive.
- Subtask 3 (50%): 2 <= n <= 1000000000, 1 <= k <= 50; the final result is positive.
Examples
Example 1
Input
512 4
Output
50
Explanation
The four operations produce 512->511->510->51->50.
Example 2
Input
1000000000 9
Output
1
Explanation
Nine trailing zeros are removed, leaving one.