import sys



readline = sys.stdin.readline

MOD = 10 ** 9 + 7

INF = float('INF')

sys.setrecursionlimit(10 ** 5)





def main():

    n = int(readline())

    print(((1000 - n % 1000) % 1000))





if __name__ == '__main__':

    main()

n = int(eval(input()))

x = 0

while x < n:

    x += 1000

print(( x - n ))
import sys

readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)


def main():
    n = int(readline())
    print(((1000 - n % 1000) % 1000))


if __name__ == "__main__":
    main()

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

-import sys - -readline = sys.stdin.readline -MOD = 10**9 + 7 -INF = float("INF") -sys.setrecursionlimit(10**5) - - -def main(): -    n = int(readline()) -    print(((1000 - n % 1000) % 1000)) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +x = 0 +while x < n: +    x += 1000 +print((x - n))