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

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

n=1
kane=1000*n

while True:
    if N<=kane:
        print(kane-N)
        break
    else:
        n+=1
        kane=1000*n

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

Solution (Python):
import math

def a():
    n = int(input())

    print((10000-n)%1000)


def b():
    print('')



def c():
    print('')



def d():
    print('')


a()

Solution (Python):
N = int(input())
sen = 1000
q = N // sen
if N > q * sen:
    print(abs(N - ((q + 1) * sen)))
else:
    print(0)

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

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

if n > 0:
    print(1000 - n)
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())
    a = int(n / 1000)
    b = int(n % 1000)
    if b == 0:
        print(0)
        return
    a += 1
    print((a * 1000) - n)
    return

if __name__ == '__main__':
    main()

Solution (Python):


if __name__ == "__main__":
    a = input()
    a = int(a)
    if a%1000 == 0:
        print(0)
    else:
        print(1000-a%1000)

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

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

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

Solution (Python):
def main():
    n = int(input())
    ans = 1000-n%1000
    if ans == 1000:
        print(0)
    else:
        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())
x=n%1000
if x==0:
    print("0")
else:
    print(1000-x)

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

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

for i in range(11):
  if i*1000 - n < 1000:
    ans = i*1000 - n
    
  elif i*1000 - n > 1000:
    i += 1
    
print(ans)

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

if N % 1000 == 0:
    ans = 0
else:
    while N > 0:
        N = N - yen
    ans = abs(N)

print(ans)

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

ans =  (1000 - N%1000) %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(((n+1000-1)//1000)*1000-n)

Solution (Python):
a = input()

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

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

C = N // 1000
T = N - C * 1000
ans = 1000 - T
if ans >= 1000:
    ans = 1000 - ans
print(ans)

Solution (Python):
import math
n = int(input())
if n >= 1000:
    s = 1000
    i = 1000
    while n > s:
        s += i
    
    print(s-n)
else:
    print(1000-n)

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

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

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

ans = N%1000
if ans!=0:
    ans = 1000-N%1000

print(ans)

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

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

Solution (Python):
import math

n = int(input())

x = math.ceil(n / 1000)
ans = (x * 1000) - n

print(ans)

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

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

s = s % 1000

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

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

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

Solution (Python):
import math
n=int(input())
if(n%1000==0):
  print("0")
else:
  k=math.ceil(n/1000)
  print((k*1000)-n)

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

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


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

Solution (Python):
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    print(math.ceil(n/1000)*1000 - n)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):

"""Untitled45.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1chuGB-wcuZOks_CainjNbE3q0Mhq_H-D
"""

n = int(input())
if n <= 1000:
  print(int(1000-n))
elif n <= 2000:
  print(int(2000-n))
elif n <= 3000:
  print(int(3000-n))
elif n <= 4000:
  print(4000-n)
elif n <= 5000:
  print(int(5000-n))
elif n <= 6000:
  print(int(6000-n))
elif n <= 7000:
  print(int(7000-n))
elif n <= 8000:
  print(int(8000-n))
elif n <= 9000:
  print(int(9000-n))
elif n <= 10000:
  print(int(10000-n))

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

if ans != 0:
  ans = 1000 - ans

print(ans)

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

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

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

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

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

Solution (Python):
N = input()


ans = int(N[-3:])

ans = 1000 - ans

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

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

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

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy



from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7

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

Solution (Python):
from collections import *






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

Solution (Python):
N = int(input())
if N<=1000:
    print(1000-N)
elif N<=2000:
    print(2000-N)
elif N<=3000:
    print(3000-N)
elif N<=4000:
    print(4000-N)
elif N<=5000:
    print(5000-N)
elif N<=6000:
    print(6000-N)
elif N<=7000:
    print(7000-N)
elif N<=8000:
    print(8000-N)
elif N<=9000:
    print(9000-N)
elif N<=10000:
    print(10000-N)

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

Solution (Python):
N=int(input())
quotient=N//1000
for i in range(quotient+1):
    N=N-1000
    if N<=0:
        break
print(abs(N))

Solution (Python):
N = input()

N_int = int(N)


if N_int <= 1000:
    print(1000 - N_int)
elif N_int <= 2000:
    print(2000 - N_int)
elif N_int <= 3000:
    print(3000 - N_int)
elif N_int <= 4000:
    print(4000 - N_int)
elif N_int <= 5000:
    print(5000 - N_int)
elif N_int <= 6000:
    print(6000 - N_int)
elif N_int <= 7000:
    print(7000 - N_int)
elif N_int <= 8000:
    print(8000 - N_int)
elif N_int <= 9000:
    print(9000 - N_int)
elif N_int <= 10000:
    print(10000 - N_int)
else: 
    print(500)

Solution (Python):
N = int(input())
if N % 1000 == 0:
    print(0)
elif N < 1000:
    i = 1000
    print(i-N)
elif N < 2000:
    i = 2000
    print(i-N)
elif N < 3000:
    i = 3000
    print(i-N)
elif N < 4000:
    i = 4000
    print(i-N)
elif N < 5000:
    i = 5000
    print(i-N)
elif N < 6000:
    i = 6000
    print(i-N)
elif N < 7000:
    i = 7000
    print(i-N)
elif N < 8000:
    i = 8000
    print(i-N)
elif N < 9000:
    i = 9000
    print(i-N)
elif N < 10000:
    i = 10000
    print(i-N)

Solution (Python):
n = input()
s=1000
f=0
if(int(n)<s):
    print(s-int(n))
else:
    if(int(n)%s==0):
        print(0)
    else:
        print(s*(int(n[0])+1)-int(n))

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

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

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

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

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

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

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

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

N=int(readline())

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

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

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

a = N %1000

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

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

Solution (Python):
import math

i = int(input())
j = math.ceil(i / 1000)
okane = j * 1000 

print(okane - i)

Solution (Python):
import  math
N=int(input())
A=N/1000
B=math.ceil(A)
if A==0:
    print(0)
else:
    print(B*1000-N)

Solution (Python):
import sys

DEBUG = False
if DEBUG:
    f=open("202007_1st/A_input.txt")
else:
    f=sys.stdin
N=int(f.readline().strip())
R=N%1000
if R==0:
    print(R)
else:
    print(1000-(N%1000))
f.close()

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

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

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

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

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

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

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

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

a = x % 1000

if a == 0:
  print("0")
  exit()

print(1000 - a)

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

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

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

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

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

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

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

if N==10000:
    print(0)
elif N>9000:
    print(10000-N)
elif N>8000:
    print(9000-N)
elif N>7000:
    print(8000-N)
elif N>6000:
    print(7000-N)
elif N>5000:
    print(6000-N)
elif N>4000:
    print(5000-N)
elif N>3000:
    print(4000-N)
elif N>2000:
    print(3000-N)
elif N>1000:
    print(2000-N)
else:
    print(1000-N)

Solution (Python):
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'
    
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()

class Tree:
    def __init__(self,inp_size=None,ls=None,init=True,index=1):
        self.LCA_init_stat=False
        self.ETtable=[]
        if init:
            if ls==None:
                self.stdin(inp_size,index=index)
            else:
                self.node_size=len(ls)+1
                self.edges,_=GI(self.node_size,self.node_size-1,ls,index=index)
        return
 
    def stdin(self,inp_size=None,index=1):
        if inp_size==None:
            self.node_size=int(input())
        else:
            self.node_size=inp_size
        self.edges,_=GI(self.node_size,self.node_size-1,index=index)
        return
    
    def listin(self,ls,index=0):
        self.node_size=len(ls)+1
        self.edges,_=GI(self.node_size,self.node_size-1,ls,index=index)
        return
 
    def dfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def bfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.popleft()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def parent(self,x):
        return self.dfs(0,func=lambda pr,prv,nx,dist:pr,root_v=-1)
 
    def topological_sort(self,x):  
        tps=[]
        q=deque([x])
        v=[None]*self.node_size
        v[x]=0
        while q:
            c=q.popleft()
            tps.append(c)
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=0
        return tps
 
    def EulerTour(self,x):
        q=deque()
        q.append(x)
        self.depth=[None]*self.node_size
        self.depth[x]=0
        self.ETtable=[]
        self.ETdepth=[]
        self.ETin=[-1]*self.node_size
        self.ETout=[-1]*self.node_size
        cnt=0
        while q:
            c=q.pop()
            if c<0:
                ce=~c
            else:
                ce=c
                for nb,d in self.edges[ce]:
                    if self.depth[nb]==None:
                        q.append(~ce)
                        q.append(nb)
                        self.depth[nb]=self.depth[ce]+1
            self.ETtable.append(ce)
            self.ETdepth.append(self.depth[ce])
            if self.ETin[ce]==-1:
                self.ETin[ce]=cnt
            else:
                self.ETout[ce]=cnt
            cnt+=1
        return
    
    def doubling_LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.depth=[None]*self.node_size
            self.depth=self.bfs(0,func=lambda pr,prv,nxt,dist:prv+1)
            self.par=self.bfs(0,func=lambda pr,prv,nxt,dist:pr)
            self.db=[self.par]
            for i in range(self.node_size.bit_length()):
                
                self.db+=[[self.db[-1][self.db[-1][i]] for i in range(self.node_size)]]
            self.LCA_init_stat=True
        dx=self.depth[x]
        dy=self.depth[y]
        if dx>dy:
            dx,dy=dy,dx
        c=self.node_size.bit_length()
        while c>0:
            if dx+c<=dy:
                x=self.db[c][x]
                dx+=1<<c
            c>>=1
        
        if x==y:
            return x
        
        c=self.node_size.bit_length()
        while c>0:
            if self.db[c][x]!=self.db[c][y]:
                x=self.db[c][x]
                y=self.db[c][y]
            c>>=1
        
        return self.par[x]
        
    def LCA_init(self,root):
        self.EulerTour(root)
        self.st=SparseTable(self.ETdepth,init_func=min,init_idl=inf)
        
        self.LCA_init_stat=True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.LCA_init(root)
        xin,xout=self.ETin[x],self.ETout[x]
        yin,yout=self.ETin[y],self.ETout[y]
        a=min(xin,yin)
        b=max(xout,yout,xin,yin)
        id_of_min_dep_in_et=self.st.query_id(a,b+1)
        return self.ETtable[id_of_min_dep_in_et]
 
    def __str__(self):
        return  str(self.edges)
 
    def show(self):
        if all([all([d==1 for nd,d in e]) for e in self.edges]):
            print( [[nd for nd,d in e] for e in self.edges] )
        else:
            print(self)
 
    def dfs2(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        dfs_tr=[x]
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
                    dfs_tr+=nb,
        return v,dfs_tr

class SparseTable: 
    def __init__(self,ls,init_func=min,init_idl=float('inf')):
        self.func=init_func
        self.idl=init_idl
        self.size=len(ls)
        self.N0=self.size.bit_length()
        self.table=[ls[:]]
        self.index=[list(range(self.size))]
        self.lg=[0]*(self.size+1)
        
        for i in range(2,self.size+1):
            self.lg[i]=self.lg[i>>1]+1
 
        for i in range(self.N0):
            tmp=[self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) for j in range(self.size)]
            tmp_id=[self.index[i][j] if self.table[i][j]==self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) else self.index[i][min(j+(1<<i),self.size-1)] for j in range(self.size)]
            self.table+=[tmp]
            self.index+=[tmp_id]
    
    
    def query(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        return self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))])
    
    
    def query_id(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        a,b=self.index[N][l],self.index[N][max(0,r-(1<<N))]
        if self.table[0][a]==self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))]):
            b=a
        return b
    
    
    def right_bound(self,pos,x):
        k=(self.size-pos).bit_length()
        for j in range(k)[::-1]:
            nx=pos+(1<<j)
            if nx<n and self.query(pos,nx+1)<=x:
                pos+=(1<<j)
        return pos
    
    
    def left_bound(self,pos,x):
        k=pos.bit_length()
        for j in range(k)[::-1]:
            nx=pos-(1<<j)
            if 0<=nx and self.query(nx,pos+1)<=x:
                pos-=(1<<j)
        return pos

    def __str__(self):
        return str(self.table[0])
 
    def print(self):
        for i in self.table:
            print(*i)

show_flg=False
show_flg=True

ans=0


n=I()
k=((n+999)//1000)*1000
ans=((n+999)//1000)*1000-n

print(ans)

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

Solution (Python):
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000


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

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

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

for i in range(11):
  if n >= 1000:
    n -= 1000
    
  if n < 1000 and n != 0:
    print(1000 - n)
    break

  if n == 0:
    print(n)
    break

Solution (Python):
N = input()

if int(N[-3:]) == 0:
    print(0)
else:
    print(1000 - int(N[-3:]))

Solution (Python):
N = int(input())
if 1 <= N <= 999:
  print(1000-N)
elif int(str(N)[1:]) ==0:
  print(0)
else:
    print(1000-int(str(N)[1:]))

Solution (Python):
import math
N=int(input())
ans=0
while (ans-N<0):
  ans+=1000

print(ans-N)

Solution (Python):


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

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

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

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

Solution (Python):
n = int(input())
if n < 1000:
    print(1000 - n)
else:
    n = str(n)
    firt = n[0]
    firt = int(firt)
    firt = str(firt)
    length = len(n) - 1
    leng = "0" * length
    fill = firt + leng
    fill = int(fill)
    res = int(n) - fill
    if res == 0: print(res)
    else:
        print(1000 - res)

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

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

Solution (Python):
a = int(input())
print(1000*bool(a%1000)-a%1000)

Solution (Python):
import math
import sys

def main():

    input = sys.stdin.buffer.readline
    n = int(input())
    if(n%1000 == 0):
        print(0)
    else:
        a = n // 1000
        print((a+1)*1000-n)

if __name__ == "__main__":
    main()

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

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

if a <1000:
    print(1000-a)
    exit()

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

B = int(a//1000+1)*1000
C = B-a
print(C)

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

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

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

if len(N) <4:
    print(1000-int(N))
elif len(N) == 5:
    print(10000-int(N))
else:
    n = (1+int(N[0]))*1000 
    if int(N) % 1000 == 0:
      print(0)
    else:
      print(n - int(N))

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

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

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

Solution (Python):
N = int(input())
M = round(N+500, -3)
if M-N == 1000:
  print(0)
else:
  print(M-N)

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

if N == 10000:
    print(0)
elif N < 1000:
    X = 1000 - N
    print(X)
else:
    for i in range(11) :
        if N < i * 1000:
            X = i * 1000 - N
            if X == 1000:
                print(0)
            else:
                print(X)
            break

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

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

T = math.ceil(N/1000)
print(1000*T-N)

Solution (Python):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
print((1000-N%1000)%1000)

Solution (Python):

a = int(input())
b = 0
while b < a:
    b = b + 1000

print(abs(a-b))

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

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

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

print(ans)

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

Solution (Python):
N = int(input())
for i in range(0,1000000,1000):
    if N <= i:
        print(i-N)
        exit()

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

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

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

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

if 0 <= N <= 1000:
    print(1000-N)
elif 1000 < N <= 2000:
    print(2000-N)
elif 2000 < N <= 3000:
    print(3000-N)
elif 3000 < N <= 4000:
    print(4000-N)
elif 4000 < N <= 5000:
    print(5000-N)
elif 5000 < N <= 6000:
    print(6000-N)
elif 6000 < N <= 7000:
    print(7000-N)
elif 7000 < N <= 8000:
    print(8000-N)
elif 8000 < N <= 9000:
    print(9000-N)
else:
    print(10000-N)

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


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

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

if len(N) == 2:
    b = int(N[-2])
    c = int(N[-1])
    x = 10*b + c
elif len(N) == 1:
    c = int(N[-1])
    x = c
else:
    a = int(N[-3])
    b = int(N[-2])
    c = int(N[-1])
    x = 100*a + 10*b + c
ans = 1000 - x
if ans == 1000:
    ans = 0
print(ans)

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

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

n = N
while n > 0:
    n -= 1000
    
print(abs(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):
str = input()
a = int(str)
c = a % 1000
if c == 0:
    c = 1000
print(1000 - c)

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

if (N >= 1000):
    while(N > 1000):
        N = N - 1000
    N = 1000 - N

else:
    N = 1000 - N

print(N)

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

Solution (Python):
n = int(input())
if n % 1000:
    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):
n=int(input())
import sys
if n<=1000:
    print(1000-n)
    sys.exit()
if n%1000==0:
    print(0)
    sys.exit()
a=n//1000
print((a+1)*1000-n)

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)
elif N < 1000:
    i = 1000
    print(i-N)
elif N < 2000:
    i = 2000
    print(i-N)
elif N < 3000:
    i = 3000
    print(i-N)
elif N < 4000:
    i = 4000
    print(i-N)
elif N < 5000:
    i = 5000
    print(i-N)
elif N < 6000:
    i = 6000
    print(i-N)
elif N < 7000:
    i = 7000
    print(i-N)
elif N < 8000:
    i = 8000
    print(i-N)
elif N < 9000:
    i = 9000
    print(i-N)
elif N < 10000:
    i = 10000
    print(i-N)

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

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

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

Solution (Python):
n = int(input())
i = 0
m = n
while (m > 0):
    m = m - 1000
    i = i + 1

print(i*1000 - n)

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

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

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

Solution (Python):
input_yen = int(input())
unit_yen = 1000

required_bill = int(float(input_yen)/unit_yen + (float(input_yen) % unit_yen > 0)) * unit_yen
print(required_bill - input_yen)

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

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

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

Solution (Python):
n = int(input())
d,q = divmod(n,1000)

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

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

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

Solution (Python):
l=int(input())
if l <= 1000:
  print(1000-l)
elif l <= 2000:
  print(2000-l)
elif l <= 3000:
  print(3000-l)
elif l <= 4000:
  print(4000-l)
elif l <= 5000:
  print(5000-l)
elif l <= 6000:
  print(6000-l)
elif l <= 7000:
  print(7000-l)
elif l <= 8000:
  print(8000-l)
elif l <= 9000:
  print(9000-l)
else:
  print(10000-l)

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

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

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