n=int(eval(input()))

res=0

cont=1

while n>0:

    n=n-(1000*cont)



print((abs(n)))
n = int(eval(input()))



while n>0:

    n=n-1000



print((abs(n)))

n = int(eval(input()))
res = 0
cont = 1
while n > 0:
    n = n - (1000 * cont)
print((abs(n)))

n = int(eval(input()))
while n > 0:
    n = n - 1000
print((abs(n)))

-res = 0 -cont = 1 -    n = n - (1000 * cont) +    n = n - 1000