Problem:
 Score : 100 points    Problem Statement We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000 -yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.      Constraints  1 \leq N \leq 10000  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output Print the amount of change as an integer.        Sample Input 1 1900      Sample Output 1 100  We will use two 1000 -yen bills to pay the price and receive 100 yen in change.       Sample Input 2 3000      Sample Output 2 0  We can pay the exact price.

Solution (Python):
n = int(input())

if n % 1000 == 0:
    print(0)
else:
    print(1000 - (n % 1000))

Solution (Python):
def main():
    n = int(input())
    if  n % 1000 == 0:
        print(0)
    else:
        print(1000 - n % 1000)
    
    
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

while n > 0 :
    n = n - 1000
    if n <= 0 :
        break

print(abs(n))

Solution (Python):
N = int(input())

if N % 1000 == 0:
    ans = 0
else:
    ans = 1000-(N % 1000)

print(ans)

Solution (Python):
N = int(input())

if N%1000==0:
    print(0)
else:
    print((N//1000+1)*1000-N)

Solution (Python):
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000 - n % 1000)

Solution (Python):
N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print(1000 - (N - ((N // 1000) * 1000)))

Solution (Python):
def main():
    n = int(input())
    if n % 1000 == 0:
        ans = 0
    else:
        ans = 1000*((n//1000) + 1) - n
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
if n%1000==0:
    print(0)
else:
    t=n//1000
    
    print((t+1)*1000-n)

Solution (Python):
n = int(input())

mon = n
while mon > 0:
    mon-=1000

print(abs(mon))

Solution (Python):
n = int(input())
x= n //1000
mod = n % 1000
if mod == 0:
  print(1000*x-n)
else:
  print(1000*(x+1)-n)

Solution (Python):
N = int(input())
if N%1000 != 0:
  print(1000-N%1000)
else:
  print(0)

Solution (Python):
N = int(input())
left = N % 1000
if left == 0:
    print(0)
else:
    print(1000 - left)

Solution (Python):
import sys
readline = sys.stdin.readline

N = int(readline())

p = 1000 - N%1000

if p == 1000:
  p = 0
print(p)

Solution (Python):
n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000 - n % 1000)

Solution (Python):
N = int(input())

print(1000 - (N % 1000) if (N % 1000) != 0 else 0)

Solution (Python):
N = int(input())

a = N % 1000
if a==0:
    print(a)
else:
    a = 1000 - a
    print(a)

Solution (Python):
n = int(input())

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

Solution (Python):
from math import *

N = int(input())
nextt = ceil(N/1000)*1000
print(nextt-N)

Solution (Python):
print((10000-int(input()))%1000)

Solution (Python):

def main():

    N = int(input())
    money = 0

    while N > money:
        money += 1000

    print(money - N)



if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
for i in range(1,100):
    x = i * 1000 - n
    if x >= 0:
        print(x)
        exit()

Solution (Python):
N = int(input())
ans = (1000-N%1000)%1000
print(ans)

Solution (Python):
n = int(input())
if n%1000==0:
  print(0)
else:
  x = n%1000
  print(1000-x)

Solution (Python):
N = int(input())

ans = N % 1000

print(0 if ans == 0 else 1000 - ans)

Solution (Python):
n=int(input())
ans=0
if n%1000==0:
  ans=0
else:
  ans=1000-n%1000
print(ans)

Solution (Python):
x = int(input())
if x % 1000 == 0:
    print(0)
else:
    print(1000-x%1000)

Solution (Python):
N = int(input())

print(1000 - ((N-1) % 1000) - 1)

Solution (Python):

N = int(input())
s = N % 1000
if s != 0:
    print(1000-s)
else:
    print(s)

Solution (Python):
import random
from functools import lru_cache
import math

def solve():
    n = int(input())
    if n < 1000:
        print(1000 - n)
    else:
        paid = math.ceil(n / 1000) * 1000
        print(paid-n)

t = 1
for _ in range(t):
    solve()

Solution (Python):
n = int(input())
print(-((-n)//1000)*1000-n)

Solution (Python):
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
d=read()
d%=1000
if d==0:
  print(0)
else:
  print(1000-d)

Solution (Python):


a=int(input())
if a%1000==0:
    print(0)
    exit()
print(1000-(a%1000))

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

print(0 if n%1000 == 0 else 1000-n%1000)

Solution (Python):



def solve(*args: str) -> str:
    n = int(args[0])

    return str(-(-n//1000)*1000-n)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):
n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000 - (n % 1000))

Solution (Python):
N=int(input())
if N%1000==0:
    print(0)
else:
    print(1000-N%1000)

Solution (Python):
n = int(input())
fac = n // 1000
if n % 1000 != 0:
    print(1000 * (fac + 1) - n)
else:
    print(0)

Solution (Python):
n=int(input())
if n%1000==0: exit(print(0))
print(1000-n%1000)

Solution (Python):
N=int(input())
if N%1000!=0:
    print(1000-N%1000)
else:
    print(0)

Solution (Python):
N = int(input())

if N % 1000:
    print(1000 - N %1000)
else:
    print(0)

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    def dump(*args):
        sys.stderr.write(str(args))

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


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
tmp = n%1000

if tmp == 0:
    print(tmp)
else:
    print(1000-tmp)

Solution (Python):
N= int(input())

if N%1000==0:
  print(0)
else:
  print(1000-N%1000)

Solution (Python):
N = int(input())
if N%1000 == 0:
  print(0)
else:
  
  a = N//1000 + 1
  print(a*1000 -N)

Solution (Python):
n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000-n%1000)

Solution (Python):
N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print((N//1000+1)*1000-N)

Solution (Python):
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  if N % 1000 == 0:
    print(0)
  else:
    print(1000*(N//1000 + 1) - N)


if(__name__ == '__main__'):
  main()

Solution (Python):
n = int(input())
if(n%1000==0):
  print(0)
else:
  print(1000 - n%1000)

Solution (Python):
import math
N = int(input())
print(math.ceil(N/1000)*1000-N)

Solution (Python):
N = int(input())


if N%1000!=0:
    print(1000-N%1000)
else:
    print(0)

Solution (Python):
a = int(input())
b = int(1000 - a % 1000)
if b == 1000:
  print(0)
else:
  print(b)

Solution (Python):
n = int(input())

n %= 1000
n = 1000 -n

if n % 1000 == 0:
    n = 0

print(n)

Solution (Python):
N = int(input())

if N % 1000 == 0: print(0)
else: print(1000 - N % 1000)

Solution (Python):
N = int(input())

while N > 0:
    N = N - 1000
print(-N)

Solution (Python):
n = int(input())
fix = 1000
if n % fix == 0:
    print(0)
else:
    n %= fix
    print(fix - n)

Solution (Python):
n = int(input())
print((1000*((n//1000)+1)-n)%1000)

Solution (Python):
n=int(input())
a=n%1000
if a==0:
    print(a)
else:
    print(1000-a)

Solution (Python):
n = int(input())

i = 0
while i*1000<n:
    i += 1

print((i)*1000-n)

Solution (Python):
N = int(input())

for i in range(11):
    if i*1000 >= N:
        print(i*1000 - N)
        exit()

Solution (Python):
a = int(input())

if a % 1000 == 0:
    print(0)
else:
    print(1000 - (a % 1000))

Solution (Python):

"""AtCoder Beginner Contest 173: A - Payment
https://atcoder.jp/contests/abc173/tasks/abc173_a
"""

import math


def main():
    N = int(input())
    print(math.ceil(N / 1000) * 1000 - N)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

while N > 1000:
    N -= 1000

print(1000-N)

Solution (Python):

n = int(input())

ans = 1000 - (n % 1000)

if ans == 1000 :
    ans = 0

print(ans)

Solution (Python):
n = int(input())
money = 1000
while True:
    if money >= n:
        print(money-n)
        exit()
    else:
        money += 1000

Solution (Python):
N=int(input())
print(1000-N%1000 if N%1000!=0 else 0)

Solution (Python):
N = int(input())
if N % 1000 == 0:
  print(0)
else:
  print(1000 - (N % 1000))

Solution (Python):
n = int(input())

a = 1000
while a < n:
    a  += 1000


print(a -n)

Solution (Python):
n = int(input())

a = n % 1000

if (a != 0):
    print(1000 - a)
else:
    print(0)

Solution (Python):
n=int(input())

if n % 1000 !=0:
    ans = ((n // 1000) + 1) * 1000 - n
else:
    ans = 0

print(ans)

Solution (Python):
N = int(input())
if N % 1000 ==0:
  print(0)
else:
  print(1000*((N//1000) +1) - N)

Solution (Python):
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000-n%1000)

Solution (Python):
def main():
    N = int(input())
    amari = N % 1000 if N % 1000 else 1000
    print(1000 - amari)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
print(1000 - n % 1000 if n % 1000 != 0 else 0)

Solution (Python):
N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print(1000 - N%1000)

Solution (Python):
n = int(input())
if n % 1000 > 0:
    print(1000 - n % 1000)
else:
    print(0)

Solution (Python):
x = int(input())
ans = x % 1000
if ans != 0:
    ans = 1000 - ans
print(ans)

Solution (Python):
N = int(input())
for i in range(20):
    if N > 1000:
        N-=1000
    else:
        break
print(1000-N)

Solution (Python):
N = int(input())
a = 0

while a*1000<N:
    a += 1

print(a*1000-N)

Solution (Python):


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


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
while n>0:
    n-=1000
print(-n)

Solution (Python):
N = int(input())
ans = N % 1000
ans = (1000 - ans) % 1000
print(ans)

Solution (Python):
N = int(input())
if N%1000==0:
  print(0)
else:
  ans = 1000 - N%1000
  print(ans)

Solution (Python):
N = int(input())

print(1000 - N % 1000 if N % 1000 != 0 else 0)

Solution (Python):

"""
Created on Sun Jul  5 21:00:39 2020

@author: NEC-PCuser
"""

N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print(1000 - (N % 1000))

Solution (Python):
def main():
  N = int(input())

  b = (N // 1000) + 1

  print((b * 1000 - N) % 1000)

if __name__ == "__main__":
  main()

Solution (Python):
n=int(input())
print(1000-n%1000 if n%1000!=0 else 0)

Solution (Python):
n = int(input())
print(0 if n%1000 == 0 else 1000-n%1000)

Solution (Python):

"""
@author: H_Hoshigi
"""
def main():
    N = int(input())

    answer = 0
    if N%1000 >= 1:
        answer = 1000 - N%1000
    print(answer)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    r, m = divmod(N, 1000)

    if m == 0:
        print(0)
    else:
        print(1000 - m)

if __name__ == "__main__":
    main()

Solution (Python):








def solve(N):
    while N > 0:
        N -= 1000
    print(-N)


if __name__ == '__main__':
    
    N = int(input())
    
    
    
    solve(N)

Solution (Python):
N=int(input())
p=N%1000

if p==0:
  print(0)
else:
  print(1000-p)

Solution (Python):
N = int(input())

N = N % 1000

if N == 0:
    print(0)
else:
    print(1000-N)

Solution (Python):
N = int(input())
if N%1000 != 0:
  print(1000 - int(N%1000))
else:
  print('0')

Solution (Python):

N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print(1000 - N % 1000)

Solution (Python):
def main():
  n = int(input())
  print((1000 - n) % 1000)


if __name__ == "__main__":
  main()

Solution (Python):
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M


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

Solution (Python):
n = int(input())
if n%1000==0:
    print(0)
else:
    n = 1000 - (n-n//1000*1000)


    print(n)

Solution (Python):
N = int(input())
if N%1000 == 0:
    print(0)
else:
    print(1000-N%1000)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def main():
    n = II()
    if n%1000 == 0:
        print(0)
    else:
        print(1000-n%1000)

if __name__ == '__main__':
    main()

Solution (Python):

N = input()

result = 1000 - int(N[-3:])

if result == 1000:
    print('0')
else:
    print(result)

Solution (Python):
n = int(input())

if n%1000 != 0:
    print(1000-(n%1000))
else:
    print(0)

Solution (Python):
N = int(input())

if N % 1000 == 0:
    print(0)
else:
    print(1000 - (N % 1000))

Solution (Python):
def main():
    N= int(input())
    price = 1000
    ans = price - N%price
    if ans == price:
        ans = 0
    print(ans)
main()

Solution (Python):
n = int(input())
print((1000 - n) % 1000)

Solution (Python):
n = int(input())
i=1
ans=0
for i in range(100):
	if i*1000>=n:
		ans = i*1000-n
		break
print(ans)

Solution (Python):
l = input()
if int(l[-3:]) == 0:
  print(0)
else:
  print(1000-int(l[-3:]))

Solution (Python):
n = input()
n = n[-3:]
n = int(n)
if n!= 0:
    print(1000-n)
else:
    print(0)

Solution (Python):

import sys
input = sys.stdin.readline
n = int(input())
print(0 if n%1000==0 else 1000-(n%1000))

Solution (Python):
n = int(input())
print((1000 - n % 1000)%1000)

Solution (Python):
N = int(input())

money = 0

while N > money:
    money += 1000

print(money - N)

Solution (Python):
n = int(input())
print(((n // 1000) + (1 if n % 1000 else 0)) * 1000 - n)

Solution (Python):
import math
n = int(input())

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

Solution (Python):
n=int(input())
if n%1000!=0:
    print((n//1000+1)*1000-n)
else:
    print(0)

Solution (Python):
N = int(input())
if N % 1000 == 0:
    print(0)
else:
    print((N // 1000 + 1) * 1000 - N)

Solution (Python):
n = int(input())

if n % 1000 == 0:
    print(0)
else:
    print(1000 - n % 1000)

Solution (Python):
import math
n = int(input())
m = math.ceil(n / 1000)
print(m * 1000-n)

Solution (Python):
N = int(input())
pay = 1000

while pay < N:
  pay += 1000
print(pay-N)

Solution (Python):
N=int(input())
if N%1000==0:
    print(0)
else:
    print(1000-N%1000)

Solution (Python):
N = int(input())

i = 1

while True:
    s = 1000 * i - N
    if s >= 0:
        break
    
    i += 1
    
print(s)

Solution (Python):
import math
N = int(input())
print((math.ceil(N/1000))*1000-N)

Solution (Python):
n=int(input())
print(-(-n//1000)*1000-n)

Solution (Python):
N = int(input())

for i in range(12):
    if i * 1000 >= N:
        print(i * 1000 - N)
        break

Solution (Python):
import math

N = int(input())
tmp = math.ceil(N / 1000)

print(1000*tmp - N)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        lower, upper = [], []
        i = 1
        while i * i <= n:
            if n % i == 0:
                lower.append(i)
                if i != n // i:
                    upper.append(n // i)
            i += 1
        return lower + upper[::-1]

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    N = Scanner.int()
    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - N % 1000)


def main():
    
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
x=(1000-n%1000)%1000
print(x)

Solution (Python):
n = int(input())

t = 1000-(n % 1000)

print(0 if t == 1000 else t)

Solution (Python):
s=int(input())
if s%1000==0:
  print(0)
else:
  print(1000-s%1000)

Solution (Python):
n=int(input())
if n%1000==0:
    ans=0
else:
    ans=1000-n%1000
print(ans)

Solution (Python):
N=int(input())
if (N%1000==0):
    print("0")
else:
    print(1000-(N%1000))

Solution (Python):
N = int(input())

print(0 if N%1000 == 0 else 1000-(N%1000))

Solution (Python):
a = int(input())
if a%1000 !=0:
  print(1000-a%1000)
else:
  print(0)

Solution (Python):
n=int(input())
c=n%1000
if c==0:
  print(0)
else:
  print(1000-c)

Solution (Python):
n = int(input())
ans = 1000 - n%1000
if ans == 1000: ans = 0
print(ans)

Solution (Python):

s = int(input()) % 1000

if s == 0:
    print(0)
else:
    print(1000 - s )

Solution (Python):
N=int(input())
if N%1000==0:
    print(0)
else:
    print(1000-(N%1000))

Solution (Python):

n = int(input())
a = n % 1000
if a == 0:
    print(0)
else:
    print(1000-a)

Solution (Python):
N = int(input())
t = N % 1000
if t:
    print(1000-t)
else:
    print(0)

Solution (Python):
n = int(input())
m = (n + 999) // 1000
print(m * 1000 - n)

Solution (Python):
N = int(input())

print(1000-N%1000 if N%1000 != 0 else 0)

Solution (Python):
N = int(input())

ans = N % 1000
ans = 1000 - ans
ans = ans % 1000

print(ans)

Solution (Python):
n=int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-(n%1000))

Solution (Python):
n=int(input())

for _ in range(1, 11):
  if 1000*_>=n:
    print(1000*_-n)
    break

Solution (Python):
n=int(input())
ans=0
if n%1000== 0:
    ans=0
else:
    ans=1000-n%1000
print(ans)

Solution (Python):
n=int(input())

a=1000

while(1):
  if a>=n:
    print(a-n)
    break
  a+=1000

Solution (Python):
n = int(input())
ans = 1000 - (n % 1000)
print(ans) if ans != 1000 else print(0)

Solution (Python):
n = int(input())
if n%1000==0:
    print(0)
else:
    i = int(n//1000)
    print((i+1)*1000-n)

Solution (Python):
N = int(input())

a = 0
while a < N:
	a += 1000
    
print(a-N)

Solution (Python):
n=int(input())
if n%1000==0:
  print(0)
  exit()
print((n//1000+1)*1000-n)

Solution (Python):
N = int(input())
a = N%1000

if a==0:
    print(0)
else:
    print(1000-a)

Solution (Python):
N = int(input())
ans = 1000 - (N % 1000)
if ans == 1000:
    print(0)
else:
    print(ans)

Solution (Python):
n=int(input())

if n%1000==0:
    print(0)
else:
    print(((n//1000)+1)*1000-n)

Solution (Python):
n = int(input())
print((1000-(n%1000))%1000)

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    ans = N % 1000
    if ans != 0:
        ans = 1000 - ans
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
a=1000-N%1000
if a==1000:
  print(0)
else:
  print(a)

Solution (Python):
n=int(input())
print(0if n%1000==0else 1000-n%1000)

Solution (Python):
import sys
import math
import bisect


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

if __name__ == "__main__":
    main()

Solution (Python):
import copy


def get_int():
    return int(input())


def get_string():
    return input()


def get_int_list():
    return [int(x) for x in input().split()]


def get_string_list():
    return input().split()


def get_int_multi():  
    return map(int, input().split())


def get_string_char_list():
    return list(str(input()))





'''
while (idx < n) and ():

    idx += 1
'''

def main():

    a = get_int() % 1000
    if a == 0:
        print(0)
    else:
        print(1000 - a)





if __name__ == '__main__':
    main()

Solution (Python):
import math
N = int(input())
M = math.ceil(N/1000)

print(M*1000-N)

Solution (Python):
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000 * (n//1000 + 1) - n)

Solution (Python):
import sys
import math


from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007

n=ii1()
ans=1000*(1+ n//1000)
if n%1000==0:
    print(0)
else:
    print(ans-n)

Solution (Python):


import math
import re
import numpy as np
import copy


S = input()
N = int(S)

res = N%1000

if res == 0:
    print(0)
else:
    print(1000-res)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - N % 1000)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
if N%1000!=0:
    print(-(N-(N//1000)*1000-1000))
else:
    print(0)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(input())
    print(((N+1000-1)//1000)*1000-N)
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
if n%1000 == 0:
  print(0)
else:
  n1=n//1000
  n2 = (n1+1)*1000
  print(n2-n)

Solution (Python):
N = int(input())

n = N%1000

if n==0:
    print(n)
else:
    print(1000-n)

Solution (Python):
n = int(input())
a = n//1000
if n%1000 != 0:
    print(1000*(a+1) - n)
else:
    print(0)

Solution (Python):
N = int(input())

tmp = N % 1000
ans = 0
if tmp != 0:
    ans = 1000 - tmp
print(ans)

Solution (Python):
N = int(input())
print((10000*1000-N)%1000)

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    
    
    
    
    
    
    
    

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


resolve()

Solution (Python):

n=int(input())
if n%1000==0:
	print(0)
else:
	v = n//1000
	print((v+1)*1000-n)

Solution (Python):
def main():
    n = int(input())
    if n % 1000 == 0:
        print(0)
    else:
        a = n // 1000
        ans = (a + 1) * 1000 - n
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())

n = n%1000
print(abs(n-1000)%1000)

Solution (Python):
N = int(input())
if N % 1000 == 0:
    print(0)
else:
    print(1000 - N % 1000)

Solution (Python):
n = int(input())
while True:
    if n <= 1000:
        print(1000-n)
        break
    else:
        n-=1000

Solution (Python):
n=int(input())

for i in range(1,11):
	if 1000*i>=n:
		print(1000*i-n)
		exit()

Solution (Python):
n = int(input())
i = 0
while True:
    i += 1
    if 1000*i >= n:
        break
print(1000*i - n)

Solution (Python):
N = int(input())
tmp = N % 1000
if tmp == 0:
    print(0)
else:
    print(1000 - tmp)

Solution (Python):
N = int(input())
N = N % 1000
if N == 0:
    print(0)
else:
    print(1000-N)

Solution (Python):
n = int(input())

ans = n % 1000
ans = 1000 - ans

if ans == 1000:
    ans = 0

print(ans)

Solution (Python):
def main():
    N = int(input())

    if N%1000 == 0:
        print(0)
    else:
        print(1000 - (N%1000))


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())

kirisute=((-1*n)//1000)*(-1)

print(abs(n-kirisute*1000))

Solution (Python):
N = int(input())
while N>0:
  N-=1000
print(-N)

Solution (Python):
n = int(input())
if n%1000:
    print(1000 - n % 1000)
else:
    print(0)

Solution (Python):
N = int(input())

answer = 1000 - N % 1000
if answer == 1000:
    print(0)
    exit()
print(answer)

Solution (Python):
N = int(input())

aaa = N % 1000

if aaa==0:
    print(0)
else:
    bbb = 1000 - aaa
    print(bbb)

Solution (Python):
a = int(input())
b = a%1000
if b == 0:
    print(b)
else:
    print(1000-b)

Solution (Python):
N = int(input())

n = N % 1000

if n == 0:
    print(0)
else:
    print(1000-n)

Solution (Python):
X=int(input())
while X>1000:
  X-=1000
print(1000-X)

Solution (Python):
n=int(input())
z=n%1000
if z==0:
  print(0)
else:
  print(1000-z)

Solution (Python):
N=input()
if N%1000==0:
    print 0
else:
    print 1000-N%1000

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n = iinput()
div,mod = divmod(n,1000)
ans = 1000*(div+1) - n if mod else 0
print(ans)

Solution (Python):
N = int(input())
a = N%1000
print(a if a == 0 else 1000-a)

Solution (Python):
cost = int(input())
payment = 1000 - (cost % 1000)
print(payment if payment != 1000 else 0)

Solution (Python):
n = int(input())
while n > 1000:
    n -= 1000
if n == 0:
    print("0")
else:
    print(1000 - n)

Solution (Python):
n = int(input())
ans = 10000-n
print(int(str(ans)[-3:]))

Solution (Python):
N = int(input())

for i in range(1,11):
    oturi = N-i*1000

    if oturi <= 0:
        print(abs(oturi))
        exit()

Solution (Python):
n = int(input())

for i in range(1,11):
    if i*1000 >= n:
        print(i*1000-n)
        break

Solution (Python):
n = int(input())

if n % 1000 == 0:
    print(0)
    exit()

md = (n+1000) // (1000)

print((md)*1000 - n)

Solution (Python):
n = int(input())
if n % 1000 == 0:
    print(0)
else:

    print(1000 -(n % 1000))

Solution (Python):
x=int(input())
if x%1000==0:
    print(0)
else:
    print(1000-x%1000)

Solution (Python):

n=int(input())
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)

Solution (Python):
n = int(input())

n %= 1000

if n != 0:
  print(1000-n)
else:
  print(0)

Solution (Python):
def resolve():
  N = int(input())
  print((1000-N%1000)%1000)

if __name__ == "__main__":
  resolve()

Solution (Python):
N = int(input())
if not N%1000:
    print(0)
else:
    print(1000-N%1000)