import math



n = int(eval(input()))



print((math.ceil(n/1000)*1000-n))

n = int(eval(input()))



p = 0

while p < n:

  p += 1000

print((p - n))

import math

n = int(eval(input()))
print((math.ceil(n / 1000) * 1000 - n))

n = int(eval(input()))
p = 0
while p < n:
    p += 1000
print((p - n))

-import math - -print((math.ceil(n / 1000) * 1000 - n)) +p = 0 +while p < n: +    p += 1000 +print((p - n))