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):
def a173(n):

    return 1000-int(n[-3:]) if int(n[-3:]) != 0 else 0

def main():
    n = str(input())
    print(a173(n))

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())
for i in range(0, n//1000+1, 1):
    n -= 1000
if n == -1000:
    print(0)
else:
    print(abs(n))

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

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

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

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

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):
a = input()
b = int(a[-3:])
if b==0:
    print(0)
else:
    c = 1000-b
    print(c)

Solution (Python):
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

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

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

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

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

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

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

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

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

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

print(-n)

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

Solution (Python):
n=int(input())
if n<=1000:
  print(1000-n)
elif 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((10000-int(input()))%1000)

Solution (Python):
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()



N = In.int()

i = 1

while i*1000<N:
    i+=1

Out.int(i*1000 - N)




if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

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

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

Solution (Python):
N = int(input())
k = N//1000
if N%1000==0:
  print(0)
else:
  print(1000*(k+1)-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):
import math
n = int(input())
m = math.ceil(n/1000)
print(m*1000-n)

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

while money < n:
    money += 1000

print(money-n)

Solution (Python):

N =int(input())

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

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

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

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

while money < N:
  money += 1000

print(money - N)

Solution (Python):


n = int(input())
r = n % 1000

if r == 0:
    print(r)
else:
    c = 1000 - r
    print(c)

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

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

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

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

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

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

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

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

while 1:
  if N<=money:
    ans=money-N
    break
  money=money+1000

print(ans)

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

Solution (Python):
import math

N=int(input())

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

Solution (Python):
a = int(input())
b = a
while True:
  if a % 1000 != 0:
    a += 1
  else:
    break
print(a-b)

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

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

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

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

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

print((1000 - k%1000)%1000)

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

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

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

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

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

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

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

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

amari = N % 1000

answer = 1000 - amari
if answer == 1000:
	answer = 0

print(answer)

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

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

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

for i in range(0, 20000 , 1000):
    if i >= n:
        break
print(i - n)

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

Solution (Python):
N=int(input())
ma=-(-N//1000)
NN=ma*1000-N
print(NN)

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

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

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

while x < n:
    x += 1000
print(x - n)

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

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

print(ans)

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

print(ans)

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

change = N%1000

if change == 0:
    print(0)
    exit()

print(1000-change)

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

print(1000 * ((N - 1) // 1000 + 1) - N)

Solution (Python):
N = int(input())
maisuu = 1
answer = 0
while(True):
    if N <= (1000*maisuu):
        answer = (1000*maisuu)-N
        print(answer)
        break
    elif N <= 10000:
        maisuu += 1
    else:
        print("error")
        break

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

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

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

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

rest = N
while rest > 0:
  rest -= 1000
print(-1*rest)

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

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

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

else:
    print(1000 - a % 1000)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):


import sys

def main():
    n = int(input())
    for a in range(1, 11):
        if n <= a * 1000:
            print(a * 1000 - n)
            break

main()

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

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

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

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

ans = n // 1000
ans1 = n % 1000
if 0 < ans1:
  ans += 1
a = ans * 1000
if a < n:
  o = n - a
  print(o)
else:
  o = a - n
  print(o)

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

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

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

zan = N % 1000

if zan == 0:
    print('0')
elif zan != 0:
    num = 1000 - zan
    print(num)

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

print(-n)

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

Solution (Python):
N=int(input())
table=[]
for i in range(11):
    m=1000*i-N
    if m>=0:
        table.append(m)
print(min(table))

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

Solution (Python):


price=int(input())
surpus=price%1000
print((1000-surpus)%1000)

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

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

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

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

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

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


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

print(change)

Solution (Python):
import sys
from io import StringIO
import unittest


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

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1900"""
        output = """100"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3000"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

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

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

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

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

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

Solution (Python):
import sys 

def A():
  n = int(sys.stdin.readline().rstrip())
  charge = (n+999)//1000 * 1000 - n
  print(charge)
  pass


def B():
  pass


def C():
  pass


def D():
  pass


def E():
  pass


def F():
  pass

if __name__ == "__main__":
  A() 
  B()
  C()
  D()
  E()
  F()

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

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

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

a = 1000 - N

while a < 0:
    a = a + 1000

print(a)

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

Solution (Python):
n = int(input())
s = 1000
while True:
	if s - n >= 0:
		break
	else:
		s += 1000
print(s - n)

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

q, mod = divmod(N, 1000)
if mod != 0:
    print((q+1)*1000 - N)
else:
    print(0)

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

temp = N%1000

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

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

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

Solution (Python):
import sys
import math


try:
    sys.stdin = open(sys.path[0] + '/input.txt', 'r')
    sys.stdout = open(sys.path[0] + '/output.txt', 'w')
except FileNotFoundError:
    pass


n = int(input())

cnt = 1 + (n // 1000)
print((1000 * cnt - n) % 1000)

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

Solution (Python):
price = int(input())
if price % 1000 == 0:
    print(0)
else:
    print(1000-(price%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())
x = (n+999)//1000
print(x*1000 - n)

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

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

number_of_bills = int(N / 1000)
change = number_of_bills*1000 - N
if change < 0:
    change += 1000
print(str(int(change)))

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

number_of_bills = int(N / 1000)
change = number_of_bills*1000 - N
if change < 0:
    change += 1000
print(str(int(change)))

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

number_of_bills = int(N / 1000)
change = number_of_bills*1000 - N
if change < 0:
    change += 1000
print(str(int(change)))

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

number_of_bills = int(N / 1000)
change = number_of_bills*1000 - N
if change < 0:
    change += 1000
print(str(int(change)))

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    n %= 1000
    if n == 0:
        return 0

    return 1000 - n


print(main())

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

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

Solution (Python):



n = int(input())

i=1
while n > i*1000:
    i+=1
q = i*1000 -n
print(q)

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

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

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

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

Solution (Python):
n = list(input())
m = int("".join(n[-3:]))
if m==0:
    ans = 0
else:
    ans = 1000-int(m)
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')



 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()

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

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:
  k = int(N/1000) + 1
  print(1000*k - N)

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

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

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

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

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

Solution (Python):
def main():
    import sys
    readline = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    x, y = divmod(n, 1000)
    if y == 0:
        print(0)
    else:
        print(1000 - y)


if __name__ == '__main__':
    main()

Solution (Python):
def A_Payment():
    
    N = int(input())
    
    i = 1
    while True:
        if 1000 * i >= N:
            return 1000 * i - N
        else:
            i += 1

result = A_Payment()
print(result)

Solution (Python):
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  
from collections import defaultdict  
from heapq import heapify, heappush, heappop, heappushpop  
from bisect import bisect_left, bisect_right  
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7



def main():
    n = i2n()
    n = (10000 - n) % 1000
    print(n)

main()

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

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

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

Solution (Python):



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

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

Solution (Python):
n = int(input())
for i in range(12):
    if 1000 * i < n <= 1000 * (i+1):
        x = n - 1000 * i
print(1000-x)

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

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

Solution (Python):
n=int(input())
for i in range(101):
    if n>i*1000:
        continue
    print(i*1000-n)
    exit(0)

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

a = n // 1000
b = n / 1000

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

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):
a = int(input())
b = int(a / 1000) + 1
c = a % 1000
if c == 0:
  print(0)
else:
  print(1000 - c)

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

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

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

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

print(1000 - (N % 1000))

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

Solution (Python):
"""
atcoder : 173A
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""

n = int(input())
print((1000 - n%1000)%1000)

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

result = money - N
print(result)

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

r = N % 1000

if not r:
  print(0)
else:
  q = N // 1000
  print((q+1) * 1000 - N)

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

x = 0
while x < n:
    x += 1000

ans = x - n
print(ans)

Solution (Python):
import math

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

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

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

A = 1000

M = int(N/A)
O = 0

if N%A == 0:
    O = 0
else:
    O = A*(M+1) - N

print(O)

Solution (Python):


import bisect
import copy
import collections
import heapq
import itertools
import math
import numpy as np
from operator import itemgetter
import scipy.misc
import sys

"""

N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
"""


N=int(input())


def main():
    print((1000-N%1000)%1000)
    return
    

if __name__ == '__main__':
    main()

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

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

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

x = 0
while x < N:
    x = x + 1000

output = x - N
print(output)

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

Solution (Python):
import math

N = int(input())
if N%1000 == 0:
    print(0)
else:
    ans = (math.floor(N/1000)+1)*1000 - N
    print(ans)

Solution (Python):
N = int(input())
change = ((N+1000-1)//1000)*1000-N

print(change)

Solution (Python):

import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	
	sys.stdin = open(name)

a = int(input())

b = a%1000

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

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

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

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

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

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

Solution (Python):
n=int(input())
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):
import math
N = int(input())
print(math.ceil(N/1000)*1000 - N)

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

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

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

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

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

r = N % 1000

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

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

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

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

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

print((1000-(n%1000))%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):
import math
N = int(input())
print(math.ceil(N/1000)*1000-N)

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

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

Solution (Python):
import math

a = int(input())
b = math.ceil(a / 1000)
print(b * 1000 - a)

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

a=N

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

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

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

print(i*1000-N)

Solution (Python):
import subprocess
import sys

code = r"""
using namespace std;

int main() {
  int n; cin >> n;
  int need = (n + 1000 - 1) / 1000;
  cout << need * 1000 - n << '\n';
  
  return 0;
}
"""

with open("main.cc", "w") as f:
	f.write(code)
    
subprocess.Popen(['g++', '-std=c++2a', '-O2', "main.cc"]).communicate()
subprocess.Popen(['./a.out'], stdin=sys.stdin, stdout=sys.stdout).communicate()

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

print(ans)

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

b = (1000-a%1000)%1000

print(b)

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

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


print(m)

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

print(m)

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

Solution (Python):

def main():
    n = int(input())
    t = 0
    while t < n:
        t += 1000
    print(t - n)

main()

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

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

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

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

s = n % 1000

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
import math
lines = list(s.rstrip("\n") for s in sys.stdin)
input = int(lines[0])
ceiled = math.ceil(input / 1000.0)
answer = ceiled * 1000 - input
print(answer)

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

Solution (Python):
import sys

MONEY = 1000
n = int(sys.stdin.readline().rstrip())

r = n % MONEY

print(MONEY - r if r > 0 else 0)

Solution (Python):
import math
n=int(input())
nn=n/1000

nn=math.ceil(nn)*1000

print(nn-n)

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

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

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

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

Solution (Python):
import math

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

Solution (Python):
n = int(input())
cnt = 0
while n%1000:
	cnt+=1
	n+=1
print(cnt)

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

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

Solution (Python):
price = input()
if not int(price) % 1000:
    print("0")
else:
    if len(price) > 3:
        result = 1000 * (int(list(price)[0])+1) - int(price)
    else:
        result = 1000 - int(price)
    print(result)

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

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

print((-1) *((-1) * n // 1000) * 1000 - n)

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

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

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

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