N = int(eval(input()))



for i in range(100):

    if 1000 * i >= N:

        break

print((1000 * i - N))

N = int(eval(input()))



for i in range(1, 11):

    if 1000 * i >= N:

        break

print((1000 * i - N))

N = int(eval(input()))
for i in range(100):
    if 1000 * i >= N:
        break
print((1000 * i - N))

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

-for i in range(100): +for i in range(1, 11):