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):
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    
    if N % 1000 == 0:
        ans = 0
    else:
        ans = 1000*(N//1000+1)-N
    
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)

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

if __name__=='__main__':
  main()

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

while n > t:
  t += 1000

print(t - n)

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

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

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

ans = a % 1000

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

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

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

Solution (Python):

d = input("")
d = int(d)

while d > 1000:
  d = d - 1000

d = 1000 - d

print(d)

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

Solution (Python):
price = int(input())
change = 1000 - price % 1000

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

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

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

flag = True
count = 0
money = 0

while(flag):
    money += 1000
    count += 1
    if money >= N:
        flag = False

print(count * 1000 - N)

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

Q = N - 1000

while Q > 0:
    Q = Q - 1000

print(abs(Q))

Solution (Python):
import math

n = int(input())

num_bills = math.ceil(n / 1000)

change = (1000 * num_bills) - n

print(change)

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

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

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

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

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

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() 
ni = lambda: int(readline().rstrip()) 
nm = lambda: map(int, readline().split()) 
nl = lambda: list(map(int, readline().split())) 

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

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

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

print(ans)

Solution (Python):

import sys
import math

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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

while a>0:
	a-=1000

print(abs(a))

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

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

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

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

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

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

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

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

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

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

    ans = 1000 - n % 1000
    print(ans)


if __name__ == '__main__':
    main()

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

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

main()

Solution (Python):

import collections
import sys
import copy
import re


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


def main():
    N = I()
    ans = 0

    while True:
        if N >= 1000:
            N -= 1000
            if N ==0:
              break
        else:
            ans = 1000-N
            break

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
my_money = 1000
for i in range(10):
  if my_money < N:
    my_money += 1000
  else:
    print(my_money - N)
    exit()

Solution (Python):
from sys import stdin
import sys
import math



s = int(input())
if s % 1000 == 0:
    print('0')
    sys.exit()
print(((s//1000)+1)*1000-s)

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

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

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

print((10000-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(0,11):
    if i*1000 >= N:
        print(i*1000 -N)
        break

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

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

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

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

for i in range(1000, 10001, 1000):
    if i - N > -1:
        print(i - N)
        break
    else:
        continue

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

Solution (Python):


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

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

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

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

Solution (Python):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

a=one_int()

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

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

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

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

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

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

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

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

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    for i in range(1, 100):
        if 1000 * i >= N:
            print(1000*i-N)
            break


if __name__ == '__main__':
    main()

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

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

print(1000 - N)

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

Solution (Python):
from math import ceil
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = None

n = i_in()
ans = -n + ceil(n/1000) * 1000

print(ans)

Solution (Python):

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

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

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

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

for i in range(1000, 11000, 1000):
   if n <= i:
    print(i-n)
    exit()

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

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

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

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

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

Solution (Python):



def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    t=(N+1000-1)//1000
    print(t*1000-N)

main()

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

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

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

Solution (Python):


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

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

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

a = math.ceil(N / 1000)
ans = (1000*a) -N

print(ans)

Solution (Python):
import sys


def resolve():
    readline = sys.stdin.readline    

    N = int(readline())
    for i in range(11):
        cal = i * 1000 - N
        if cal >= 0:
            print(cal)
            break


if __name__ == "__main__":
    resolve()

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

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

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

while n > 0:
    n -= 1000

n *= -1
print(n)

Solution (Python):
n=int(input())
if(n%1000==0): print(0)
else: print((n//1000+1)*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 >= 1 and N <= 1000:
  print(1000 - N)
elif N >= 1001 and N <= 2000:
  print(2000 - N)
elif N >= 2001 and N <= 3000:
  print(3000 - N)
elif N >= 3001 and N <= 4000:
  print(4000 - N)
elif N >= 4001 and N <= 5000:
  print(5000 - N)
elif N >= 5001 and N <= 6000:
  print(6000 - N)
elif N >= 6001 and N <= 7000:
  print(7000 - N)
elif N >= 7001 and N <= 8000:
  print(8000 - N)
elif N >= 8001 and N <= 9000:
  print(9000 - N)
else:
  print(10000 - N)

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

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

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

n = int(input())

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

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

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

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

Solution (Python):

import math


N = int(input())


tmp = math.ceil(N / 1000)
ans = 1000*tmp - N


print(ans)

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

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

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

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

ans = []
for i in range(11):
    if 1000 * i - n >= 0:
        ans.append(1000*i - n)

print(min(ans))

Solution (Python):
def main():
    n = int(input())
    for i in range(1000,11000,1000):
        if i - n >= 0:
            print(i-n)
            return
            
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())
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())
n=N%1000
if n==0:
  print(0)
else:
  print(1000-n)

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

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

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

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

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

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

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

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

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

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

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

main()

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

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

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

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

for i in range(10+1):
    if 1000*i>=N:
        print(1000*i-N)
        break
    else:
        pass

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

ans = (1000 - N % 1000) % 1000

print(ans)

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

if n%1000 == 0:
  print(0)
elif n<= 999:
  print(1000-n)
else:
  print(1000-int(str(n)[1:]))

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

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

r=0
g=N%1000

r=1000-g
if r==1000:
  r=0

print(r)

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

Solution (Python):
N=int(input())
otsuri=10000
for i in range(11) :
    if 1000*i-N>=0 :
        coin=1000*i-N
        otsuri=min(otsuri,coin)
print(otsuri)

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

lst = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
if N in lst:
  thousands = int(N / 1000)
else:
  thousands = int(N / 1000) + 1

print((1000 * thousands) - N)

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

m=n-(1000*x)

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

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

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

Solution (Python):
import numpy as np

N = int(input())

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

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

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

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

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

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

Solution (Python):

import os
from sys import stdin, stdout


def solve(tc):
  n = int(stdin.readline().strip())
  rem = n%1000
  print(1000-rem if rem>0 else 0)


tcs = 1
tc = 1
while tc <= tcs:
  solve(tc)
  tc += 1

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

Solution (Python):
import math
import bisect
import copy





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

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

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

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

Solution (Python):
S = int(input())
pay = 1000
while S > pay:
    pay += 1000
else:
    print(pay - S)

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

Solution (Python):
N=int(input())
list = []
for i in range(10):
  s = (i+1)*1000-N
  if s >= 0:
    list.append(s)
print(min(list))

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

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

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

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



if __name__ == '__main__':
    main()

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

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




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

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

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():
    n = int(input())
    ans = 0
    for i in range(1,10+1):
        num = 1000*i
        if num >= n:
            ans = i
            break

    print(abs(1000*ans - n))


if __name__ == "__main__":
    main()

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

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
if N % 1000 == 0:
    print(0)
else:
    ans = 1000 - N % 1000
    print(ans)

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

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

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

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

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

ans = n

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

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

amari = N % 1000

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

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

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

while(N > k):
    k += 1000

turi = k - N

print(turi)

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

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

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

if v != 0:
    v = 1000 - v


print(v)

Solution (Python):


N = int(input())

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

Solution (Python):



def main():
    a = int(input())
    m = int(a / 1000)
    n = int(a % 1000)
    if n != 0:
        m += 1
    print(int((m * 1000) - a))


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
r = 0
while True:
  if 0 < N:
    N = N - 1000
  else:
    break
print(N * -1)

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

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

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

N = N - 1000
for j in range (10):
    if N - (1000*j) <= 0 :
        print(abs(N-(1000*j)))
        break

Solution (Python):

N = int(input())

temp = N % 1000

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

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

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

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

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

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

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

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

times = N // 1000

ans = N - 1000*times

if ans != 0:
    ans = abs(1000 - ans)

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

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

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

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

Solution (Python):
""" A
    https://atcoder.jp/contests/abc173/tasks/abc173_a
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

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

if __name__ == "__main__":
    _N = readInteger()

    print(main(_N))

Solution (Python):

import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

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

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

n = 0
while (1000*n-N < 0):
    n = n+1

print(1000*n-N)

Solution (Python):
origin, charge = divmod(int(input()), 1000)
if charge != 0:
  print(1000 - charge)
else:
  print(charge)

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

x = N %1000

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

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

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

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

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

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

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

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

print((10000 - n)%1000)

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

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

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

q, r = divmod(p, 1000)
if(r == 0):
  r2 = 0
else:
  r2 = 1000 - r

print(r2)

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

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

print(pay-n)

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

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

def main():
    n = int(input())
    a = n // 1000

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

if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):



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


if __name__ == "__main__":
    main()

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

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

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

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

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


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

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

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

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

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

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

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

Solution (Python):
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(1000-a)
else:
    print(a)

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

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

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

print(1000 - N)

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

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

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

for i in range(10):
    if 1000*(i+1)>= N:
        break
print(1000*(i+1)- N)

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

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

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

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

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

N = int(input())
q, mod = divmod(N, 1000)

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

Solution (Python):
n = int(input())
def main():
    for i in range(1, 11):
        a = 1000*i
        if n <= a:
            ans = a - n
            print(ans)
            return ans

main()

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

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

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

ans = 0

while N >= 1000:
  N = N - 1000

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

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

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

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

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

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())
ans = 0

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

for i in range(10000):
    if n % 1000 == 0:
        break
    ans += 1
    n += 1

print(ans)

Solution (Python):
n=int(input())
ans=0
if n%1000==0:
    print(ans)
    exit()
for i in range(10000):
    n+=1
    ans+=1
    if n%1000==0:
        break
print(ans)