n = int(eval(input()))

for i in range(1, 11):

    if i*1000 >= n:

        break

print((i*1000 - n))
n = int(eval(input()))



for i in range(0, 20000 , 1000):

    if i >= n:

        break

print((i - n))

n = int(eval(input()))
for i in range(1, 11):
    if i * 1000 >= n:
        break
print((i * 1000 - n))

n = int(eval(input()))
for i in range(0, 20000, 1000):
    if i >= n:
        break
print((i - n))

-for i in range(1, 11): -    if i * 1000 >= n: +for i in range(0, 20000, 1000): +    if i >= n: -print((i * 1000 - n)) +print((i - n))