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.
number = int(input())
thausand_num = number / 1000
if number % 1000 == 0:
  print(0)
else:
  print(number - thausand_num * 1000)
number = int(input())
thausand_number = int(number / 1000)
if number % 1000 == 0:
  print(0)
else:
  print((thausand_number + 1) * 1000 - number)