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

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

x = n//1000
y = 1000 * (x+1) - n
if y != 1000:
  print(y)
else:
  print('0')

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

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

Solution (Python):
import math
N = int(input())
for i in range(math.floor(N/1000)):
  N -= 1000
if N != 0:
  print(1000 - N)
else:
  print(0)

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

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

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

ans=1000-n%1000

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

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

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

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

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)
n_coin = 0
change = 1000*m - N
print(change)

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

for i in range(10000):
    n = N-(i+1)*1000
    if n<=0:
        break

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

Solution (Python):
pay = int(input())
answer = 1000 - pay
while answer < 0:
  answer += 1000
print(answer)

Solution (Python):
from math import log10

n = int(input())

i = 1

while True:
    if n <= 1000 * i:
        print((1000 * i) - n)
        break

    i += 1

Solution (Python):


import numpy as np
hairu = int(input())

turi = 1000 - hairu%1000

print(turi%1000)

Solution (Python):
N = int(input())
if N >= 1000:
    M = str(N)
    X = M[1:]
    O = int(X)
    if O == 0:
        print(0)
    else:
        print(1000-O)
else:
    O = int(N)
    print(1000-O)

Solution (Python):
n = (input())
x, y = divmod(int(n), 1000)
if y == 0:
    print(0)
else:
    ans = (1000 * (x + 1)) - int(n)
    print(ans)

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

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

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

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

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

a = n % 1000

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

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

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

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

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

pp = (nn + 999) // 1000 * 1000

print(pp - nn)

Solution (Python):
import sys

n = int(sys.stdin.readline().rstrip("\n"))
n_r = n % 1000
if n_r == 0:
    print(0)
else:
    print(1000-n_r)

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

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

Solution (Python):

N = int(input())
a = N % 1000
if N < 1000 :
    ans = 1000- a

elif a == 0:
    ans = 0
elif a < 500:
    ans = 1000 - a

else:
    ans = 1000-a

print(ans)

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

print(-n%1000)

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

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

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

S=N%1000

if S !=0:
    print(abs(S-1000))
else:
    print(0)

Solution (Python):
n = int(input())
c = n // 1000
c_2 = n % 1000
if c_2 != 0:
	c += 1

ans = (c*1000)-n

print(ans)

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

a = n % 1000

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

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

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

Solution (Python):

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

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

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

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

Solution (Python):
import sys
import numpy as np

 
N = int(input())



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

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

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
ans=0
while 1:
    if n%1000==0:
        print(ans)
        break
    n+=1
    ans+=1

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

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

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

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

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

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

Solution (Python):

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

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

while n>=0:
    if 0<n<=1000:
        print(1000-n)
    n-=1000

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

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

Solution (Python):


def main():
    A = int(input())

    s = A % 1000

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





if __name__ == '__main__':
    main()

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

while 1 == 1:
    if n > 0:
        n = n - 1000
    else:
        print(-n)
        break

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

Solution (Python):
n=eval(input())
f=(n//1000)
o=n/1000
if o==f:
  print(0)
else:
  p=(f+1)*1000-n
  print(p)

Solution (Python):
import math
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n
 
print(val)

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

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

a= N % 1000
oturi=1000-a

if a == 0:
    oturi =0
    print(oturi)

else:
    oturi=1000-a
    print(oturi)

Solution (Python):
i = input().split()
i=int(i[0])
if i<=1000:
  print(1000-i)
else:
  k=1000-i%1000
  if k==1000:
    print(0)
  else:
    print(k)

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

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

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

Solution (Python):
value = int(input().strip())

exc = value % 1000

print(1000-exc if exc > 0 else 0)

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

    return (1000 - (N % 1000)) % 1000

print(main())

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

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):
n = int(input())

i = 0
a = n

while a > 0:
    a -= 1000
    i += 1

print(i*1000 - n)

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

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

Solution (Python):
import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict
 


 

k = int(input())
 


 


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

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:
  print((n//1000 + 1)*1000 - n)

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

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

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

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

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

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

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

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

a = n // 1000

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

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

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

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

print(ans)

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

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

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

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

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

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

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

A = N % 1000

if A > 0:
      B=1000-A
      print(B)
else:
      print(A)

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

    ans = 1000 - x
else:
    ans = 1000 - N

print(ans)

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

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter



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

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

if n%1000==0:
  print(0)
else:
  print(int(math.ceil(n/1000.0)) * 1000-n)

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

x = 0
while True:
    if (n + x) % 1000 == 0:
        break
    x += 1

print(x)

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

print(ans)

Solution (Python):
N = int(input())
ans = []
for i in range(1,12):
    ans.append(((i*1000)-N))
print(min([i for i in ans if i >= 0]))

Solution (Python):

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

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

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

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

Solution (Python):

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

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

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

devide = int(N/1000)

if N%1000==0:
    print(0)
elif devide>0:
    print((devide+1)*1000-N)
else:
    print(1000-N)

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

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

for i in range(1,11):
  if n <= i*1000:
    a=i
    break

print(a*1000-n)

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

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

Solution (Python):
import sys

def getA(n):
    if 0 == n:
        return 0
    return 1000 - n

data = sys.stdin.readlines()
for line in data:
    if not "" == line.rstrip():
        v = '000' + line.rstrip()
        print(getA(int(v[-3:])))

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

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

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

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

if __name__ == "__main__":
    main()

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

print(ans*1000 - N)

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

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

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

sur = N % 1000

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

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

Solution (Python):

import sys
import numpy as np


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
def Main(N):
    d, m  = divmod(N, 1000)
    if m == 0:
        return 0
    else:
        return (d+1)*1000 - N

print(Main(N))

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

if N < 1000:
    print(1000-N)
    exit()
else:
    p = N//1000
    mod = N % 1000
    if mod != 0:
        print(1000-mod)
    else:
        print(0)

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

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

Solution (Python):
def main():
    N = int(input())
    answer = solve(N)
    print(answer)


def solve(N):
    if N % 1000 == 0:
        return 0
    else:
        return 1000 - (N % 1000)


if __name__ == "__main__":
    main()

Solution (Python):
import sys


def resolve(in_):
    n = int(in_.read())

    return (1000 - n % 1000) % 1000


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


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())
a = 0
while(a < n):
  a += 1000
print(a-n)

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

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

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

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

print(ans)

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

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

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

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

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

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

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

Solution (Python):
def main():

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

if __name__ == "__main__":
    main()

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

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

while(True):
    if n <= 1000:
        ans = 1000 - n
        break
    n -= 1000
    
print(ans)

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

Solution (Python):
from math import *
from copy import *
from string import *				
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
import math
import math
import time
from queue import Queue


def seive(n):
	l=[True]
	l=l*(n+1)
	for i in range(2,int(sqrt(n))+1):
		if(l[i]==True):
			val=i*i
			while(val<len(l)):
				l[val]=False
				val+=i
	prime=[]
	for i in range(2,len(l)):
		if(l[i]==True):
			prime.append(i)
	return prime

def dp(l,i,n,val,ans):
	if(i>=n or val<0):
		return 1000000
	elif(val==0):
		return 0
	else:
		if(ans[i]==1000000):
			ans[i]=min(min(1+dp(l,i+1,n,val-l[i],ans),1+dp(l,i,n,val-l[i],ans)),dp(l,i+1,n,val,ans))
		return ans[i]
from queue import Queue
def factors(n):
	l=[]
	for i in range(1,int(sqrt(n))+1):
		if(n%i==0):
			if(n//i==i):
				l.append(i)
			else:
				l.append(i)
				l.append(n//i)
	return l
def check1(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v-=1
def check2(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v+=1

def up(n):
	j=n-1
	while(j>0):
		if(n%j==0):
			break
		j-=1
	return j		
def fac(n):
	c=1
	i=1
	while(i<=n):
		c*=i
		i+=1
	return c
def check_happy(n):
	ss=set()
	print(n)
	while(n!=1):
		val=n
		s=0
		print(val)
		while(val!=0):
			s+=(val%10)**2
			val=val//10
		print(val)
		print("hi")
		if(val in ss):
			return False
		else:
			n=val
			ss.add(n)
	return True
if __name__ == '__main__':
	n=int(input())
	print(1000*(int(math.ceil(n/1000)))-n)

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

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

Solution (Python):
N = int(input())
P = 1000
while True:
    if P - N >= 0:
        print(P - N)
        break
    P += 1000

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

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

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

x = math.ceil(N/1000)

print(x * 1000 - N)

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

Solution (Python):
N = input()
N = N[-3:]

if N == '000':
    print(0)
else:
    N = int(N)
    print(1000-N)

Solution (Python):
n = int(input())
ans = 100000
for i in range(15):
    if i*1000 - n >= 0:
        ans = min(i*1000-n, ans)

print(ans)

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

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

Solution (Python):
money = int(input())
yen = 0 
while yen < money:
  yen = yen + 1000

print(yen - money)

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

result = A%1000

if result != 0:
    result = 1000 - result

print(result)

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

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

a = abs(a)
print(a)

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

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

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

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

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

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

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

Solution (Python):
N = int(input().zfill(4)[-3:])
if N == 0:
    print(N)
else:
    print(1000-N)

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

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

i = 1
while(True):
  change = 1000*i - N
  if change < 0:
    i+=1
  else:
    break

print(change)

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

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

a= math.ceil(n / 1000)

print (a * 1000 -n )

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

x=x%1000
x=1000-x
if x==1000:
    x=0
print(x)

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

Solution (Python):
N = int(input())
count = 0
money = 1000
while N > money * count:
    count += 1
print(money * count - N)

Solution (Python):
import sys

def main():
	N = int(input())
	n = N / 1000
	m = N % 1000
	if m == 0 or n == 0:
		print(m)
	else:
		print(1000-m)

if __name__ == "__main__":
	main()

Solution (Python):

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

if __name__ == "__main__":
    main()

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

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

for i in range(10000, 0, -1000):
    if i - n >= 0:
        ans = i - n
    else:
        break
      

print(ans)

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

Solution (Python):
a = input()

b = 1000

while int(a) > b:
	b += 1000

print(b-int(a))

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


print(ans -n)

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

mod = N % 1000
if mod == 0:
  result = 0
else:
  result = 1000 - mod

print(result)

Solution (Python):




N = int(input())

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

print(chash - N )

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

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

digit = len(str(n))

if digit < 4:
    answer = 1000 - n
else:
    three_digits = str(n)[-3:]
    if three_digits == '000':
        answer = 0
    else:
        answer = 1000 - int(three_digits)
print(answer)

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
tmp,res = 0,0
tmp = n - (n//1000)*1000
if tmp == 0:
    res = 0
else:
    res = 1000-int(tmp)
print(res)

Solution (Python):
n = input()
if int(n) <= 1000:
  print(1000-int(n))
else:
  if int(n) % 1000 == 0:
    print(0)
  else:
    x = 1000-(100 * int(n[1]) + 10 * int(n[2]) + int(n[3]))
    print(x)

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

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

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

while N > 1000:
    N = N - 1000

print(1000 - N)

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

ans = a % 1000

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

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

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

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

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

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

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

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

S = int(N / 1000)

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

Solution (Python):
N = int(input())
tmp = 0
for i in range(11):
    tmp += 1000
    if tmp >= N:
        print(tmp-N)
        break

Solution (Python):
N = int(input())
div, mod = divmod(N, 1000)
if mod > 0:
    print(1000 - mod)
else:
    print(0)

Solution (Python):
import math
N = int(input())
rest = math.ceil(N % 1000)
if rest == 0:
    print(0)
else:
    print(1000 - rest)

Solution (Python):
n=int(input())
res=0
cont=1
while n>0:
    n=n-(1000*cont)

print(abs(n))

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

for i in range(1,11):
    tmp = i*1000
    if n==tmp:
        print(0)
        break
    else:
        if n - tmp < 0:
            print(abs(n-tmp))
            break

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

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

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

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

Solution (Python):
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
num = int(stdin.readline().rstrip())
a = int(num/1000)+1
res = (a*1000-num) % 1000
print(res)

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

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

if n < 1000:
    print(1000 - n)

elif n % 1000 == 0:
    print(0)

else:

    x = n // 1000

    y = (x+1)*1000

    print(y-n)

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

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

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

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

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

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

if __name__ == "__main__":
    main()

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

print(s)

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

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

Solution (Python):
N = input()

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

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

a = 1000

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

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

Solution (Python):
import os

N = int(input())

modN = N % 1000
if modN != 0:
    res = 1000 - modN
else:
    res = 0

print(res)

Solution (Python):
from sys import stdin, setrecursionlimit, stdout




def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())

res=['YES', 'NO']





test_case=1
while test_case:
    test_case-=1




    n=ii()+999
    x=n//1000
    print(x*1000-n+999)

Solution (Python):
N = int(input())
if N < 1000:
    print(1000-N)
else:
    
    L = str(N)
    L1 = str(L[-3] + L[-2] + L[-1])
    N1 = int(L1)
    if N1 == 0:
        print(0)
    else:
        print(1000 - N1)

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

    print(abs(n))
    
resolve()

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

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

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

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

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

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

while n >= 1000:
    n -= 1000

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

Solution (Python):




import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N = int(input())

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

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

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

print(a)

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:
    x=n%1000
    print(1000-x)

Solution (Python):
n = input()
if len(n) < 3:
    print(1000- int(n))
else:   
    value = n[-3]+n[-2]+n[-1]
    
    value_int = int(value)
    if value == '000':
        print(0)
    else:
        print(1000 - value_int)

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

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

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

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

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

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

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

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