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())

i = n//1000 + 1

if (n%1000==0 and n>=1000):
    print(0)
else:
    ans = 1000*i - n
    print(ans)

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

Solution (Python):
N = int(input())
A=int(N/1000)+1

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

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

Solution (Python):


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

print("{}".format(ans))

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

Solution (Python):


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

print("{}".format(ans))

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

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

print(-n)

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

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

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

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

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

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

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

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

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

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

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

k = 1000
i = 1
flag = True
while flag:
  a = i*k - n
  if a < 0:
    i += 1
  else:
    flag = False
print(a)

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

res = n % 1000

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

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

n = N % 1000

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

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))


def resolve():
    n = ii()
    tar = n % 1000
    print(1000 - tar if tar != 0 else 0)

if __name__ == "__main__":
    resolve()

Solution (Python):
dash  =int(input())
otsuri1=dash%1000
if otsuri1==0:
  print(0)
else:
     otsuri2=1000-otsuri1
     print(otsuri2)

Solution (Python):

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

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

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

n = I()

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

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


main()

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
for i in range (10):
	if N <= 1000:
		ans = 1000 - N
	else:
		N -= 1000
print(ans)

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

Solution (Python):
N = int(input())
ans = 0
if 1 <= N <= 10000:
    if N%1000 != 0:
        ans = ((N//1000) + 1)*1000 - N
    else:
        ans = 0
else:
    ans = "choose another number"
print(ans)

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):
import math
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


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


if __name__ == "__main__":
    main()

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

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())
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())
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())
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())
if N % 1000 == 0:
    print(0)
else:
    print(1000 - (N % 1000))

Solution (Python):
n = int(input())
a = 1000
x = 1
while True:
  if int(a * x) >= n:
    break
  x += 1

print(int(a * x) -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 % 1000))

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):
s = input()
a = [int(c) for c in s]


if len(a) < 4:
    print(1000 - int(s))
elif a[-3] != 0:
    print((a[-4]+1)*1000 - int(s))
elif int(s) % 1000 != 0:
    print((a[-4]+1)*1000 - int(s))
else:
    print(0)

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

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

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

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

if n%1000 != 0:
  m = n//1000 + 1

if m != 0:
    m = m*1000 - n

print(m)

Solution (Python):
import math

N = int(input())

if N >=1000:
    N2 = math.ceil(N/1000)*1000
else:
    N2 = 1000

print(N2-N)

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

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

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

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=1





def solve():


    
    
        

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








        
if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):
            sys.stdin=open('input1.txt', 'r')
            sys.stdout=open('output1.txt','w')
        else:
            input=sys.stdin.readline
    solve()

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=0





def solve():


    
    
        

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








        
if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):
            sys.stdin=open('input1.txt', 'r')
            sys.stdout=open('output1.txt','w')
        else:
            input=sys.stdin.readline
    solve()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
print(1000 * int(n % 1000 != 0) - n % 1000)

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

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

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

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

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
print((1000 - N % 1000) % 1000)

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())
print((1000-n%10000)%1000)

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:
    ans = 0
else:
    ans = 1000 - N % 1000
print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]

import sys


from itertools import accumulate 
import bisect 

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

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

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

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

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

while N>1000:
    N = N - 1000

print(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(abs(N%1000-1000))

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

Solution (Python):

def f(y):

    if 1 <= y <=999:
        print(1000-y)
    elif 1000<= y <= 10000 :
        b = int(y / 100)
        c = int(str(b)[1])
        g = 9-c
        h = int(y/10)
        i = int(str(h)[2])

        if y %1000==0:
            print("0")
        elif y % 500==0 and y % 1000!=0:
            print("500")
        elif y % 100==0 and y % 500!=0:
            f = 10-c
            print(f*100)
        elif y % 10 ==0 and y % 100!=0:
            j =10-i
            print(g*100+j*10)
        elif y % 10!=0:
            k = int(str(y)[3])
            l = 9 - i
            m = 10-k
            print(g*100+l*10+m)


y = input()
x = f(int(y))

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

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

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

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

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

Solution (Python):
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()
for i in range(1,100):
    v = 1000 * i

    if N <= v:
        print(v-N)
        exit()

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

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

N = 10000 - N

print( str(N % 1000) )

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

Solution (Python):

a=int(input())
b=(1000-a%1000)%1000
print(b)

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

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

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--n//1000*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())
n = math.ceil(N/1000)*1000

print(n-N)

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:
    print(0)
else:
    print(1000-N%1000)

Solution (Python):
N = int(input())
contador = 0
m = 1
while (contador < 1):
    if m*1000 >= N:
        contador = 1
    else:
        m=m+1
print(m*1000 - N)

Solution (Python):
import sys












stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    
    
    
    
    
    
    if n%1000 == 0:
        print(0)
    else:
        maisu = n//1000 + 1
        oturi = 1000*maisu - n
        print(oturi)


if __name__ == '__main__':
    solve()

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

if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):

N = 0
while((1 > N) | (N > 10000) | (type(N) is not int)):
	N = int(input())

tmp = N / 1000
i = 0
while(True):
    if(i >= tmp):
    	break
    i += 1

charge = i * 1000 - N
print(charge)

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

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

Solution (Python):
import math
def main():
  p = int(input())
  p2 = math.ceil(p/1000)*1000
  ans = p2 -p
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

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

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

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

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

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left, bisect_right 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
res = N%1000
if res==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())
a = n / 1000
if int(a) == a:
	print('0')
else:
	a = int(a) + 1
	a = a * 1000
	print(a-n)

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

for i in range(20):
    amari = 1000*i - n
    if amari >= 0:
        print(amari)
        break

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

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

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

Solution (Python):
n =int(input())
t = 1000-n
while(t<0):
    t+=1000
print(t)

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

Solution (Python):
import math

n = int(input())
n=(n/1000)
c=math.ceil(n)
a=round((c-n)*1000)
print(a)

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

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)%1000)

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

MOD = N % 1000
ANS = 1000 - MOD

if (MOD == 0):
  print(0)
else:
  print(ANS)

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

Solution (Python):
a=int(input())
n=0
while n<a:
    n+=1000
print(n-a)

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

Solution (Python):
N = int(input())
for i in range(1,10+1):
    a = 1000*i - N
    if a >= 0:
        print(a)
        break

Solution (Python):
import math
from collections import Counter,deque,defaultdict
L=lambda:list(map(int,input().split()))
M=lambda:map(int,input().split())
I=lambda:int(input())
IN=lambda:input()

def solve():
    n=I()
    if n%1000==0:
        print(0)
    else:
        print(1000-n%1000)
for _ in range(1):
    solve()

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

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

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

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)%1000)

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

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

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

Solution (Python):
import math

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

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

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

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

Solution (Python):
def main():
    n = int(input())
    result = 0
    for i in range(1, 11):
        if 1000 * i - n < 1000 and 1000 * i - n >= 0:
            print(1000 * i - n)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
if 0 == N % 1000:
    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):
price = int(input())

if price%1000==0:
  print(0)
else:
  otsuri = 1000 - price%1000
  print(otsuri)

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

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

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

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

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

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

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

while Num > 0:
    OTURI = 1000 - Num
    Num -= 1000
  
print(OTURI)

Solution (Python):
N=int(input())
M=0
while True:
  if 1000*M>N or 1000*M==N:
    print(1000*M-N)
    break
  else:
    M+=1

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    if n % 1000 == 0:
        print(n % 1000)
    else:
        print(1000 - (n % 1000))
    return


if __name__ == "__main__":
    solve()

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

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

Solution (Python):
def payment(N):
    if N % 1000 == 0:
        return 0
    else:
        return 1000 - N % 1000

if __name__ == '__main__':
    N  = int(input())
    print(payment(N))

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

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

Solution (Python):
N = int(input())
print(-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())

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

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

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

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

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

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

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

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

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

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

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

print(ans)

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

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    r = N % 1000
    if r == 0:
        print(0)
    else:
        print(1000 - r)

if __name__ == '__main__':
    solve()

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

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

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

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

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

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

Solution (Python):


N = int(input())

C = int(1000 - N % 1000)
C = int(C % 1000)

print("{}".format(C))

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


print(main())

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

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

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

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

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

amari = n % 1000

if amari == 0:
    print(0)
else:
    oturi = (1000 - amari)
    print(oturi)

Solution (Python):
print(int(str(1000 - int(input()[-3:]))[-3:]))

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

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

Solution (Python):

"""
Created on Thu Jul  9 15:33:42 2020

@author: TatsuyaYamamoto
"""

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

Solution (Python):









import sys
input = sys.stdin.readline

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

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

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

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

output = 0
if money <= 1000:
  output = 1000 - money
elif money % 1000 == 0:
  output = 0
else:
  output = 1000 - (money % 1000)
  
print(output)

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

Solution (Python):
N=int(input())
p=N//1000+min(1,N%1000)
print(1000*p-N)

Solution (Python):
print((10**7-int(input()))%1000)

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

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


N = int(input())

if N % 1000 == 0:
	print(0)
else:
	payment = (N//1000 + 1) * 1000
	print(payment - 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%1000)

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

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

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

Solution (Python):
s = int(input())
for i in range(1,11):
  if (1000 * i) >= s:
    print((1000 * i) - s)
    break

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

while x <= n:
    x += 1000

print((x - n) % 1000)

Solution (Python):
def main():
    m = int(input()) % 1000
    print(str(0 if m == 0 else 1000 - m))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    m = int(input()) % 1000
    ans = 0 if m == 0 else 1000 - m
    print(str(ans))


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    arg = int(input())
    if arg % 1000 == 0:
        ans = 0
    else:
        ans = 1000 - (arg % 1000)
    print(str(ans))


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time

readline = sys.stdin.readline
 
IPS = lambda: readline().rstrip()
IP = lambda: int(readline().rstrip())
MP = lambda: map(int, readline().split())
LS = lambda: list(map(int, readline().split()))

def solve():
    for _ in range(1):
        n = IP()
        d = int(n//1000)
        print( ((d+1)*1000 - n)%1000)
       
       
if __name__ == "__main__":
    solve()

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

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

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

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

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

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

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

Solution (Python):
import math

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

Solution (Python):
price = int(input())
sen = 1000
senCnt = int(price / 1000)
num = 0

if price % sen != 0:
    senCnt = senCnt + 1
    sen = sen * senCnt
    num = sen - price
    
print(num)