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.
a = input()

a= int(a)

x=(1000 - a)
y=abs(x)





#input 1900  print 100 (2000)
#input 3000  print 0 (3000)
a = input()
a= int(a)

if 1<= a < 1000:
    print(1000 - a)
if 1000 < a < 2000:
    print(2000 - a)
if 2000 < a < 3000:
    print(3000 - a)
if 3000 < a < 4000:
    print(4000 - a)
if 4000< a < 5000:
    print(5000 - a)
if 5000< a < 6000:
    print(6000 - a)
if 6000< a < 7000:
    print(7000 - a)
if 7000 < a < 8000:
    print(8000 - a)
if 8000 < a < 9000:
    print(9000 - a)
if 9000 < a <10000:
    print(10000 - a)
if a == 1000:
    print(0)
if a == 2000:
    print(0)
if a == 3000:
    print(0)
if a == 4000:
    print(0)
if a == 5000:
    print(0)
if a == 6000:
    print(0)
if a == 7000:
    print(0)
if a == 8000:
    print(0)
if a == 9000:
    print(0)
if a == 10000:
    print(0)





#input 1900  print 100 (2000)
# input 1525 print 475 (2000)
# input 2500 print 500 (3000)

