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.
N = input()
first_num = int(list(N)[0])
price = int(N)
price -= 1000 * first_num
print(price)
N = int(input())
for i in range(11):
    b = i * 1000
    c = b - N
    if c >= 0:
        break
print(c)