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

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	N = inputInt()

	for i in range(100000):
		tmp = i * 1000
		ans = tmp-N
		if ans >= 0:
			print(ans)
			sys.exit()



if __name__ == "__main__":
	main()

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

print((10000-n)%1000)

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

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

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

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

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

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

mod = n % 1000

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

Solution (Python):
from sys import exit




n, = map(int, input().split())


while n > 1000:
    n -= 1000

print(1000-n)

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

if 1<= a < 1000:
    print(1000 - a)
if 1000 < a < 2000:
    print(2000 - a)
if 2000 < a < 3000:
    print(3000 - a)
if 3000 < a < 4000:
    print(4000 - a)
if 4000< a < 5000:
    print(5000 - a)
if 5000< a < 6000:
    print(6000 - a)
if 6000< a < 7000:
    print(7000 - a)
if 7000 < a < 8000:
    print(8000 - a)
if 8000 < a < 9000:
    print(9000 - a)
if 9000 < a <10000:
    print(10000 - a)
if a == 1000:
    print(0)
if a == 2000:
    print(0)
if a == 3000:
    print(0)
if a == 4000:
    print(0)
if a == 5000:
    print(0)
if a == 6000:
    print(0)
if a == 7000:
    print(0)
if a == 8000:
    print(0)
if a == 9000:
    print(0)
if a == 10000:
    print(0)

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

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

Solution (Python):
import math

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

if n > m:
    result = n - m
else:
    result = m - n
    
print(result)

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

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

Solution (Python):
inp = input()
 
value = int(inp)
 
amari = value % 1000

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

  print(result)

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

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

ret = 0
if n % 1000 != 0:
    ret = 1000 - (n % 1000)
print("{}".format(ret))

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

b = N % 1000

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

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

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

Solution (Python):
N = int(input())
S = divmod(N, 1000)
if S[1] == 0:
  print (S[1])
else:
  print (1000 - S[1])

Solution (Python):

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

Solution (Python):

N = int(input())
N = N % 1000

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

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

else:
  print(1000-n)

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

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

Solution (Python):
def II(): return int(input())
N=II()
for i in range(1,101):
  x=1000*i
  if x>=N:
    break
ans=x-N
print(ans)

Solution (Python):
import math as m
money=int(input())
if(m.ceil(money/1000.0)==m.floor(money/1000.0)):
  print("0")
elif(m.ceil(money/1000.0)<m.floor(money/1000.0)):
  print(money%1000)
else:
  print(1000-(money%1000))

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

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


while N >= 0:
  N -= 1000
  if N == 0:
    break

print(abs(N))

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

thousand = int(price/1000)

if price % 1000 == 0:
    print("0")
else:
    oturi = 1000 - (price - (1000 * thousand))
    print(oturi)
    pass

Solution (Python):
N = int(input())
if N%1000 == 0:
    print(0)
else:
    Str = str(N)
    if len(Str) > 3:
        K = (int(Str[0]) + 1) * 1000
        print(K - N)
    else:
        print(1000 - N)

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

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

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

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

Solution (Python):
import math

n = int(input())
x = math.ceil(n/1000)
s = 1000*x

if n > s:
    result = n - s
else:
    result = s - n
    
print(result)

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

ans = 0

if n == 10000:
	ans = 0
else:
	for i in range(1000,11000,1000):
		if 0 < (i - n) < 1000:
			ans = (i - n)
			break
		elif i == n:
			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())
if n % 1000 == 0:
    print(0)
else:
    ans = (n//1000+1)*1000 - n
    print(ans)

Solution (Python):
import math

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

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

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

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


while N >= 0:
  N -= 1000
  if N == 0:
    break

print(abs(N))

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

Solution (Python):
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)

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

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

Solution (Python):
N = int(input())
minn=1000
if N <1 or N>10000:
	print(' ')
elif N%1000==0:
	print(0)
else:
	for i in range(1000,10001,1000):
		if N<i:
			print(i-N)
			break

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

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve():
    n = II()
    print(-n % 1000)
    return



if __name__ == '__main__':
    solve()

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

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

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

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

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

elif (N>1000 and temp == 0):
    print(temp)
else:
    res = 1000 - N
    print(res)

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

N = N % 1000

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

Solution (Python):
def resolve():
    N = input()

    if N == '10000':
        print(0)
        return

    if int(N) <= 1000:
        print(1000 - int(N))
        return

    if (N[1] == '0' and N[2] == '0' and N[3] == '0'):
        print(0)
        return

    ans = 1000 * (int(N[0]) + 1) - int(N)
    print(ans)



resolve()

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

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

Solution (Python):
        
try:
    N = int(input())
    
    if N>=1 and N<=10000:
        if N % 1000 == 0:
            print(0)
        else:
            integer = N//1000
            integer +=1 
            print((integer*1000) - N)
   
            
        
        
except Exception as e:
    print(e)

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

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

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

Solution (Python):
def main():
    n = int(input())
    while True:
        if (n >= 1000):
            n -= 1000
            if n==0:
                print(n)
                return
        else:
            print(1000-n)
            return


if __name__=='__main__':
    main()

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

for i in range (11):

    if(N<=1000*(i+1)):
        pre = i+1
        break

ans = pre*1000 - N

print(ans)

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

Solution (Python):
import math

A = int(input())

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

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

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

Solution (Python):
N = input()
if int(N) < 1001:
    x = N
elif int(N[-3]+N[-2]+N[-1]) == 0:
    x = 1000
else:
    x = N[-3]+N[-2]+N[-1]
print (1000 - int(x))

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

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

elif N>=1000:
  print(1000-N%1000)
 
elif N<1000:
  print(1000-N)

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

a = N//1000

if 1000*a != N:
  print(1000*(a+1)-N)

else:
  print(0)

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

for i in range(1, 100):
    if ((i * 1000) > x):
        print((i * 1000) - x)
        break
    elif(x==(i*1000)):
        print("0")
        break

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

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

resolve()

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

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

x = N % 1000

Otsuri = 1000-x

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

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

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

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

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

num_1000yen = 0
temp = N

while(temp > 0):
  temp -= 1000
  num_1000yen += 1
otsuri = 1000*num_1000yen - N

print(otsuri)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)



from collections import deque

import itertools


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


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


if __name__ == "__main__":
    main()

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

n_r = n % 1000

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

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

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

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

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

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

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

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

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


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

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

a = 10000 - n
if n == 0:
    print(0)

for i in range(10):
    if a >= 1000:
        a = a - 1000
    else:
        print(a)
        break

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

Solution (Python):
def solution():
    n=int(input())
    print((n+1)//2)
def sol():
    n=int(input())
    print(((n//1000)+1)*1000-n if(n%1000!=0) else 0)
if(__name__=='__main__'):
    sol()

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

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

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

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

n = 1000 - N
if N == 2000 or N == 3000 or N == 4000 or N ==5000 or N == 6000 or N == 7000 or N == 8000 or N == 9000 or N == 10000or N == 0:
  print(0)
elif 1000 < N:
  m = n * (-1)
  if m < 10:
    print(1000-m)
  elif m < 100:
    print(1000-(int(str(m)[-2])*10) + (int(str(m)[-1])))
  else:
    print(1000-((int(str(m)[-3])*100) + (int(str(m)[-2])*10) + (int(str(m)[-1]))))
else:
  print(n)

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

if __name__ == '__main__':
    main()

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


def log(*args):
    print(*args, file=sys.stderr)


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

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

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

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

while True:
    a += 1000
    if a >= n:
        print(a - n)
        break

Solution (Python):
n = int(input()) 
c = [ i*1000 - n for i in range(1,20)]
ans = float('inf')
for i in c:
    if i >= 0:
        ans = min(i,ans)
print(ans)

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

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

Solution (Python):
import math

N = int(input())

div = math.ceil(N / 1000)

turi = div * 1000 - N

print(turi)

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

b = 1000 - int(a[-3:])

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

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

while(1):
    in_value %= 1000
    if in_value == 0:
        break
    elif in_value < 1000:
        in_value = 1000 - in_value
        break
print(in_value)

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

if n % 1000 != 0:
  ans = 1000 - n % 1000
else:
  ans = 0

print(ans)

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

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

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

Solution (Python):
n = int(input())
if 1000 > n:
  print(1000 - n)
else:
  p = 1000 - int(str(n)[1::])
  print(p if p != 1000 else 0)

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

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())

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

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

print((1000-a%1000)%1000)

Solution (Python):
n = [i for i in range(1000,10001,1000)]
m = int(input())
for i in n:
    if i > m or i == m:
        a = i - m
        break
print(a)

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

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

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

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

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

Solution (Python):
import math
n=int(input())
if(n<1000):
    print(1000-n)
elif(n%1000!=0):
    a=int(math.floor(n//1000))
    print(((a+1)*1000)-n)
else:
    print("0")

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

if n% 1000 is 0:
    print(0)
elif n<1000:
    print(1000-n)
else:
    e = n % 1000
    print(1000-e)

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

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

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

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

Solution (Python):
n = int(input())
o = (1000 - (n % 1000)) % 1000
print(f"{o}")

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N = I()

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

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

if N < 1000:
    print(1000-N)

elif N == 1000:
    print(0)

elif 1000<N<2000:
    print(2000-N)

elif N == 2000:
    print(0)


elif 2000<N<3000:
    print(3000-N)

elif N == 3000:
    print(0)

elif 3000<N<4000:
    print(4000-N)

elif N == 4000:
    print(0)

elif 4000<N<5000:
    print(5000-N)

elif N == 5000:
    print(0)

elif 5000<N<6000:
    print(6000-N)

elif N == 6000:
    print(0)

elif 6000<N<7000:
    print(7000-N)

elif N == 7000:
    print(0)

elif 7000<N<8000:
    print(8000-N)

elif N == 8000:
    print(0)

elif 8000 < N < 9000:
    print(9000-N)

elif N == 9000:
    print(0)

elif 9000<N<10000:
    print(10000-N)

elif N == 10000:
    print(0)

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    ans = 0
    if N % 1000 == 0:
        ans = 0
    else:
        ans = 1000 - (N+1000) % 1000
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
cost = input()
cost = int(cost)
div, mod = divmod(cost, 1000)
if mod == 0:
    bills = div
    change = 0
else:
    bills = div + 1
    change = 1000 - mod
print(change)

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


if 1000 - d == 0 or d == 0:
    print(0)
else:
    print(1000 - d)

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

count = 0

while a%1000 != 0 :
    a +=1
    count += 1
print(count)

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

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

b=int(a/1000)

if 1000>a:
  print(1000-a)

elif 1000*b-a==0:
  print(0)

else:
  print(1000*(b+1)-a)

Solution (Python):
import math

N = int(input())

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

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

Solution (Python):
n = int(input())
if n > 9000:
  print(10000 - n)
  quit()
  
kazu = list(str(10000 - n))[0]
print((10 - int(kazu)) * 1000 - n)

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

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

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

def resolve():
    N,=pin()
    print ((-N)%1000)

resolve()

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

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

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

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

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

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

res = N // 1000
if N % 1000 != 0 :
    res += 1

con = res * 1000
oturi = con - N

print(oturi)

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

c = math.ceil(a / 1000)

print(c * 1000 - a)

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

print(abs(N))

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

Solution (Python):
N=int(input())
A=0
for i in range(0,N):
    i=i+1
    A=str(i)+"000"
    A=int(A)
    if N<=A:
        print(A-N)
        break

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

Solution (Python):
N = int(input())
cnt = 0
m, d = divmod(N, 1000)
if d == 0:
    print(0)
else:
    print(1000 - d)

Solution (Python):
N = int(input())
cnt = 0
m, d = divmod(N, 1000)
if d == 0:
    print(0)
else:
    print(1000 - d)

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

Solution (Python):
N = input()
L=list(N)
ans =0
if int(N)<1000:
    ans = 1000-int(N)
elif int(N)%1000==0:
    ans = 0   
elif int(N)>1000:
    N2 = L[1]+L[2]+L[3]
    ans = 1000-int(N2)
print(ans)

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

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

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

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

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

nn=math.ceil(nn)*1000

print(nn-n)

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

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

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

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

for i in range(10):
    N -= 1000
    if N < 0:
        N += 1000
        print(1000-N)
        break
    elif N == 0:
        print(N)
        break

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

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int):
    ret = (1000 - (N % 1000)) % 1000
    print(ret)
    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())
if N % 1000:
    mai = N // 1000 + 1
else:
    mai = N // 1000
print(1000 * mai - N)

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

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

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

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


def main():
    n = int(si())
    while n > 1000:
        n -= 1000
    print(1000-n)


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

if x % 1000 == 0:
    print(0)
else:
    x = str(x)
    y = x[-3:]
    y = int(y)
    print(1000 - int(y))

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

Solution (Python):
import sys

n = int(input())
if n==10000 or n==1000 or n==2000 or n==3000 or n==4000 or n==5000 or n==6000 or n==7000 or n==8000 or n==9000:
  change = 0
  
elif 10000 > n >= 1000:
    hyaku=(n%1000)
    change = 1000 - hyaku
else:
  change = 1000-n

print(change)

Solution (Python):
import math

N = int(input())

div = math.ceil(N / 1000)

turi = div * 1000 - N

print(turi)

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

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

while N > 1000:
    N = N - 1000

print(1000-N)

Solution (Python):
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

N=int(input())

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

Solution (Python):
"""
https://atcoder.jp/contests/intro-heuristics/tasks/intro_heuristics_a
"""

import numpy as np


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    focus = N % 1000
    result = 1000 - focus if focus != 0 else 0
    print(result)


main()

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

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

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

Solution (Python):
n = input()
a = int(n[:1])+1
ans = a*1000-int(n)
if(ans == 1000):
    print(0)
elif ans>1000:
    print(1000-int(n))
elif ans<0:
    print(0)
else:
    print(ans)

Solution (Python):
import sys






def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))




def main():
	n=II()
	if n%1000==0:
		print(0)
	else:
		print((n//1000)*1000+1000-n)


if __name__ == "__main__":
	main()

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**18


if __name__ == "__main__":
    n = int(input())
    a = 1000
    while True:
        if a >= n:
            break
        a+=1000
    print(a-n)

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

Solution (Python):
import  math
li = int(input())
x = math.ceil(li / 1000)

print(x * 1000 - li)

Solution (Python):
a =  input()
a = int(a)
b = a
cnt = 0
while True:
    b -= 1000
    cnt +=1
    if b <= 0:
        break
print(cnt*1000 - a)

Solution (Python):
def main():
    N = int(input())
    remainder = N % 1000
    quotient = int(N / 1000)
    ans = 0
    if N < 1000:
        ans = 1000 - N
    elif remainder == 0:
        ans = 0
    elif remainder > 0:
        ans = 1000 - remainder

    print(f'{ans}')


if __name__ == '__main__':
    main()

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