def main():

    N = int(eval(input()))



    change = -N % 1000

    print(change)





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))



    ans = - N % 1000

    if ans < 0:

        ans += 1000



    print(ans)





if __name__ == '__main__':

    main()

def main():
    N = int(eval(input()))
    change = -N % 1000
    print(change)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    ans = -N % 1000
    if ans < 0:
        ans += 1000
    print(ans)


if __name__ == "__main__":
    main()

-    change = -N % 1000 -    print(change) +    ans = -N % 1000 +    if ans < 0: +        ans += 1000 +    print(ans)