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

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

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

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

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

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

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

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

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

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

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:
    ans = 0

else:
    ans = 1000 - n % 1000

print(ans)

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

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

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

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

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

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

Solution (Python):
def solve(n, debug=0):
    m = 1000
    r = n % m
    return 0 if r == 0 else m - r


def main(istr, ostr):
    n = int(istr.readline())
    print(solve(n), file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

Solution (Python):



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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

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

if __name__ == '__main__':
    main()

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

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

Solution (Python):



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


if __name__ == '__main__':
    main()

Solution (Python):



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


if __name__ == '__main__':
    main()

Solution (Python):



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


if __name__ == '__main__':
    main()

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

Solution (Python):
a = input()
amari = int(a)%1000
otsuri = 1000 - amari
if otsuri == 1000:
  otsuri = 0

print(otsuri)

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

Solution (Python):



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

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

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

Solution (Python):
import math

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

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

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

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

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

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

Solution (Python):

def main():
	N = int(input())
	while N > 0:
		N = N - 1000
	print(-N)


if __name__ == '__main__':
	main()

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

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

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

Solution (Python):
import math
n=int(input())
x=10000000
for i in range(1000):
  if i*1000>=n:
  	x=min(i*1000-n,x)
  
print(x)

Solution (Python):



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


if __name__ == '__main__':
    main()

Solution (Python):



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


if __name__ == '__main__':
    main()

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

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

Solution (Python):



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


if __name__ == '__main__':
    main()

Solution (Python):



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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):






import math
import statistics
import numpy as np
import queue
import itertools
import functools 

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

Solution (Python):
S = int(input())
while True:
    if S <= 1000:
        break
    S -= 1000

print(1000-S)

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

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

x = (1000 - N%1000)%1000

print(x)

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

Solution (Python):
import math
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b) 

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

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

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

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

Solution (Python):
import math
payment = int(input().rstrip())
if (payment/1000) > math.floor(payment/1000):
    p_1 = math.floor(payment/1000)+1
else:
    p_1 = payment/1000

change = int(p_1*1000 - payment)
print(change)

Solution (Python):
import math
payment = int(input().rstrip())
if (payment/1000) > math.floor(payment/1000):
    p_1 = math.floor(payment/1000)+1
else:
    p_1 = payment/1000

change = int(p_1*1000 - payment)
print(change)

Solution (Python):



def main(n):
    m = n % 1000
    if m != 0:
        return 1000 - m
    else:
        return m


if __name__ == "__main__":
    n = int(input())
    print(main(n))

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

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

change = (Y - n) %1000
print(change)

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

print((10000-N)%1000)

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

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

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

for i in range(1000, 11000, 1000):
    if i >= N_value: 
        print(i-N_value)
        break

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

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

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

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

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

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

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

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

Solution (Python):

from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement


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

Solution (Python):

from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement


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

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

Solution (Python):
import math

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

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

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

Solution (Python):
import math

price = int(input())
payment = math.ceil(float(price) / 1000) * 1000
result = payment - price
print(int(result))

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

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

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

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

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

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

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

bucks = 1000

if payment%bucks == 0:
  change = 0
else:
  receive = payment//bucks + 1
  change = receive*bucks - payment

print(change)

Solution (Python):
import math

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

main()

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

answer = 1000 - (N%1000)
answer = answer%1000

print(answer)

Solution (Python):
n = int(input())
keta = int(n/1000)

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

Solution (Python):

N=int(input())
ans=(1000-(N%1000))%1000
print(ans)

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

N = int(input())

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

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

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

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

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

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

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

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

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

Solution (Python):






































def abc173_a(lines):
    N = int(lines[0])
    amari = N % 1000
    if amari == 0:
        answer = 0
    else:
        answer = 1000 - amari
    return [answer]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1900']
        lines_export = [100]
    elif pattern == 2:
        lines_input = ['3000']
        lines_export = [0]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = abc173_a(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

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

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

Solution (Python):

N=int(input())
if N>=0 and N<=1000:
	i=1
if N>1000 and N<=2000:
	i=2
if N>2000 and N<=3000:
	i=3
if N>3000 and N<=4000:
	i=4
if N>4000 and N<=5000:
	i=5
if N>5000 and N<=6000:
	i=6
if N>6000 and N<=7000:
	i=7
if N>7000 and N<=8000:
	i=8
if N>8000 and N<=9000:
	i=9
if N>9000 and N<=10000:
	i=10
x=1000*i-N
print(x)

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

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

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

if __name__ == "__main__":
    resolve()

Solution (Python):

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

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

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

if __name__ == "__main__":
    resolve()

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

num = math.ceil(N / 1000)

oturi = num * 1000 - N

print(oturi)

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

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

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

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

ans = money - N
print(ans)

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

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


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

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

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

Solution (Python):
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000 - 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())
for i in range(11):
    if i*1000 - n >= 0:
        print(i*1000 - n)
        break

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

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 else 0)

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

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

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

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

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

while n>0:
    n=n-1000

print(abs(n))

Solution (Python):
import sys
import math
N = int(input())
if not ( 1 <= N <= 10000 ): sys.exit()

ans = str(10000 - N)
print(int(ans[-3:]))

Solution (Python):




n = str(input())



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

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

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

if __name__ == "__main__":
    main()

Solution (Python):


a = int(input())




print("{}".format((1000-(a%1000))%1000))

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

Solution (Python):
N = int(input(""))
if N % 1000 == 0:
    N1 = N // 1000
else:
    N1 = N // 1000 + 1

print(N1 * 1000 - N)

Solution (Python):


def main():

    N = int(input())

    if N % 1000 == 0:
        ans = 0

    else:
        ans = 1000 - (N % 1000)

    print(ans)


if __name__ == "__main__":
    main()

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


print(ans)

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

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

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

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

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

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

m = N % 1000

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

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

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

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

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

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

amari = N % 1000

if amari > 0:
	answer = 1000 - amari
else:
  	answer = amari
        
print(answer)

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

n%=1000

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

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

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

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




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

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

Solution (Python):


def solve():
    price = int(input())
    mod = price % 1000
    return (1000 - mod) % 1000

print(solve())

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

sen = -(-n // 1000)
ans = sen * 1000 - n

print(ans)

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

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

Solution (Python):
import math
import sys
from collections import Counter
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    while n > 0:
        n -= 1000
    print(-n)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
N = input()
m = len(N)
if m > 3:
    N = N[-3:]

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

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

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

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

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

Solution (Python):

import sys
rl = sys.stdin.buffer.readline

N = int(rl())

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

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

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

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

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

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

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

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

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

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

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

print(-N % 1000)

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

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

hyaku = N % 1000


ans = None
if hyaku == 0:
    ans = 0
else:
    ans = 1000 - hyaku

print(ans)

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

for i in range(20):
    t = 1000 * i
    otsuri = t - N
    
    if otsuri >= 0:
        break

print(otsuri)

Solution (Python):
from math import ceil

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

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

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

ans=price%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):
N= input()
x=int(N)
if x<1000:
    print(1000-x)
if x==1000:
    print(0)
if x > 1000:   
    while True: 
	    x -= 1000
	    if x < 1001:
		    break      
    print(1000-x)

Solution (Python):


import itertools
import math
import sys

INF = float('inf')


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


def main():

    sys.setrecursionlimit(10 ** 6)

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


if __name__ == '__main__':
    main()

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

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

if __name__ == "__main__":
    solve()

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

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

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

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

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

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

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

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

sa = 10000 - N
ans = sa % 1000

print(ans)

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

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

cash = 1000

if n % cash == 0:
  print(0)
else:
  while cash < n:
    cash += 1000
  print(cash - n)

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

if n%1000 == 0:
  ans=n%1000

else:
  num=n//1000+1
  ans=num*1000-n

print(int(ans))

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

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

pay = 1000
while pay - n < 0:
    pay += 1000
print(pay - n)

Solution (Python):
int_num = int(input())
n_surplus = int_num % 1000

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

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

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

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

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

Solution (Python):
import math

amount = int(input())
payment = math.ceil(amount/1000)*1000

print(payment - amount)

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

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

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

p = 0
while p < n:
  p += 1000
print(p-n)

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

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

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

p = 0
while p < n:
  p += 1000
print(p-n)

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

p = 0
while p < n:
  p += 1000
print(p - n)

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

print(ans)

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

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

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


print(rem)

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

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

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

Solution (Python):
S = 1e3

def main():
    n = int(input())
    r = n % S
    if r == 0:
        return int(r)
    else:
        return int(S - r)

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

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

total=math.ceil(N/1000)*1000

print(total-N)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

print((1000-n)%1000)

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

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

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

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

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

Solution (Python):

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

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

num = n // 1000

if n % 1000 == 0:
    pass
else:
    num += 1

ans = 1000 * num - n

print(ans)

Solution (Python):
input_number = int(input())
number = 1000

n = input_number % number
if n > 0:
  print(number - n)
else:
  print(n)

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

while N>1000:
    N=N-1000

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

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

a= s%1000

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

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

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

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

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

else:
	N1=N%1000

	print(1000-N1)

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

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

else:
	N1=N%1000

	print(1000-N1)

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


if __name__ == "__main__":
    main()

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

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

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

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

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

paid = (1000 - cash % 1000) % 1000
print(paid)

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

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

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

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

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

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

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

while n > 1000:
    n -= 1000

print(1000 - n)

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

Solution (Python):
n = int(input())
l = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
for i in l:
    if n <= i:
        r = i
        break
result = r - n
print(result)