We will buy a product for N yen (the currency of Japan) at a shop. If we use only…
- User
We will buy a product for N yen (the currency of Japan) at a shop.
If we use only 1000-yen bills to pay the price, how much change will we receive?
Assume we use the minimum number of bills required.
Constraints
- 1 \leq N \leq 10000
- N is an integer. Input
Input is given from Standard Input in the following format:
N
Output
Print the amount of change as an integer.
Examples
Input
1900
Output
100
Input
3000
Output
0
Assistant
pythonn = int(input()) print((1000 - n % 1000) % 1000)Wait, wait, let me think again. Oh right! Because the change is (next multiple of 1000) minus N. Because the next multiple is (if N is already a multiple of 1000, then it's N. Otherwise, it's the next one). So the next multiple can be calculated as ((N + 999) // 1000) * 1000. Alternatively, (N // 1000 + (N % 1000 !=0 )) * 1000.
But another way is to realize that the next multiple of 1000 after N is (N + 999) // 1000 * 1000. Then subtract N.
But there's a simpler way. The remainder when divided by 1000 gives the excess. So for N=1900, 1900 % 1000 is 900. So the change is 1000 - 900 = 100. But for N=3000, 3000%1000 is 0, so 1000-0=1000, but then 0. Wait, no. Wait, if N is exactly divisible by 1000, the change is 0. So the formula 1000 - (N % 1000) gives 1000 -0 =1000. Which is wrong. So we need to handle that case.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.