

n=int(eval(input()))

for i in range(1000,10001,1000):

	num=i-n

	if num >=0:

		print(num)

		break
n=int(eval(input()))

for i in range(1000,10001,1000):

	if i>=n:

		print((i-n))

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

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

-    num = i - n -    if num >= 0: -        print(num) +    if i >= n: +        print((i - n))