import math

N = int(eval(input()))



n = math.ceil(N/1000)

ans = (n*1000) - N



print(ans)

import math

N = int(eval(input()))

n = math.ceil(N/1000)*1000



print((n-N))
import math

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

import math

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

-n = math.ceil(N / 1000) -ans = (n * 1000) - N -print(ans) +n = math.ceil(N / 1000) * 1000 +print((n - N))