Problem:
 Score : 100 points    Problem Statement We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000 -yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.      Constraints  1 \leq N \leq 10000  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output Print the amount of change as an integer.        Sample Input 1 1900      Sample Output 1 100  We will use two 1000 -yen bills to pay the price and receive 100 yen in change.       Sample Input 2 3000      Sample Output 2 0  We can pay the exact price.

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

        
main()

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

Solution (Python):
number = float(input())
n=number/1000
for step in range(1,11):
  if step>=n:
    i=step
    break
given = i*1000
change=given-number
print(int(change))

Solution (Python):




import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)

S = 1000 

def 関数(n):
    res = n % S
    if res == 0:
        return res
    else: 
        res = S - res
        return res

def çözmek():
    N = int(input())
    res = []
    res.append(関数(N))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()

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

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

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

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

Solution (Python):



n = int(input())

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

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

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

Solution (Python):
N = int(input())
count = 0
count1 = N
while True:
    count1 -= 1000
    if count1 <= 0:
        count += 1000
        break
    count += 1000
print(count - N)

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

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




if __name__=="__main__":
    main()

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

Solution (Python):


LI = lambda: list(map(int, input().split()))


N = int(input())


def main():
    ans = (1000 - (N % 1000)) % 1000
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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

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

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

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

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

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 1000-A!=1000:
    print(1000-A)

else:
    print(0)

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

Solution (Python):
a = input()

st = str(a)


if st[-3:] == "000":
  print(0)


else:
  z = st[-3:]
  print(1000 - int(z))

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

d = n//1000

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

Solution (Python):
def Next(): return input()
def NextInt(): return float(Next())


N = round(NextInt()*0.0010, 3)
import math
ans = math.ceil(N)
print(int(ans*1000-N*1000))

Solution (Python):
def main():
    n = int(input())
    x, mod = divmod(n, 1000)
    if mod:
        x = (x +1)*1000
    else:
        x = x * 1000
    print(x - n)

if __name__ == "__main__":
    main()

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

while N > 0:
  N = N - 1000

if N < 0:
  N = N * -1

print(N)

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

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

while True:
  sum = 1000 * tickets
  if n <= sum:
    print(sum - n)
    break
  tickets = tickets + 1

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys

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())
N = I()


l = len(str(N))

if l <= 3:
    a = 1000 - N
elif N % 1000 == 0:
    a = 0
else:
    a = 1000 - (N % 1000) 

print(a)

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

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

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

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

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

Solution (Python):
import sys
import math
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)
else:
    print(10000-n)

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

Solution (Python):
price = int(input())
count=1
cal=price
while cal > 1000:
        cal=cal-1000
        count=count+1
print(1000*count-price)

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

Solution (Python):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

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

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

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

Solution (Python):


a = int(input())

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

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

Solution (Python):
N = int(input())
a = N // 1000
b = N % 1000

if b ==0:
    print(0)
else:
    if N<=1000:
        print(1000-b)
    else:
        print(1000*(a+1)-N)

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

while True:
    ans = 1000*i - num
    i+=1
    if ans >= 0:
        break

print(ans)

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

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

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

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

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

ans = 1000 - (a % 1000)

if ans == 1000:
    ans = 0

print(ans)

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

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

Solution (Python):
N = input()

A = (int(N[-3:]) - 1000)*-1

if A == 1000:
 A = 0

print(A)

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

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

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

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

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

ans = []

for i in range(0,11):
  if (1000 * i) - N  >= 0:
    ans.append((1000 * i) - N )
    
print(min(ans))

Solution (Python):
def main():
  N = input()
  if int(N)%1000==0:
    print("0")
    return
  if len(N)<4:
    print(1000 - int(N))
  else:
    print(1000 - int(N[len(N)-3:]))

if __name__ == "__main__":
    main()

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

q = ceil(n/1000)

print(1000*q - n)

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

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

ans = 0
for i in range(1, 100000):
    
    ans += 1000
    if ans >= n:
        print(ans - n)
        exit()

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

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

b = a % 1000

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

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

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

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

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

if n >= 1000:
    n = int(str(n)[1:])

if n > 0:
    ans = 1000 - n
else:
    ans = 0

print(ans)

Solution (Python):
S = int(input())
ans=0
ans =int(S/1000)

if S%1000>0:
    ans+=1
otsuri=ans*1000-S
print(otsuri)

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

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

amari = N%1000

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

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

b = a % 1000

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

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

Solution (Python):
n = int(input())
keta = 0
nn = n
while nn > 0:
    nn = nn - 1000
    keta += 1
turi = keta * 1000 - n
print(turi)

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

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

while N > 0:
    N -= 1000

print(abs(N))

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

Solution (Python):
import sys
import numpy as np
import math  
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate 
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache 

def main():
    n = int(input())
    if n % 1000 == 0:
        print('0')
    else:
        print((n // 1000 + 1) * 1000 - n)
    return 0

if __name__ == "__main__":
    main()

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

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

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

flag = True
num = 1
while(flag):
    if(num * 1000 < N):
        num += 1
    else:
        flag = False

print(num * 1000 - N)

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

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

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

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

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

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

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

Solution (Python):
if __name__ == "__main__":
    num = int(input())

    while True:
      new_num = num - 1000
      if new_num <= 0:
        ans = new_num * -1
        break
      num = new_num
    print(ans)

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

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

Solution (Python):


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

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

Solution (Python):
import math

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

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

Solution (Python):
N = int(input())
for i in range(0,10001,1000):
  if (i-N) > 0:
    print(i-N)
    break
  elif i == N:
    print(0)
    break
  else:
    pass

Solution (Python):
import sys
import math

price = int(sys.stdin.readline().strip())

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

Solution (Python):
N = input()

if len(N) <= 2:
    print(1000 - int(N)) 
    
else:
    N_1 = N[-3] + N[-2] + N[-1]
    if N_1 == "000":
        print(0)
    else:
        print(1000-int(N_1))

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

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

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

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

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

Solution (Python):

walet = 1000

pay = int(input())

charge = 0

for i in range(10):
  charge = pay - walet
  if charge <= 0:
    break
  else:
    walet += 1000

print(abs(charge))

Solution (Python):
import math
def main():
    N = int(input().rstrip())
    use = math.ceil(N/1000)
    print(1000*use - N)
    
if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):
n = input()


x = n[-3:]


if x == '000':
    x = 1000


print(1000-int(x))

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

cost = 0
while(cost<N):
    cost += 1000

print(cost-N)

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

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

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

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

remain =  math.ceil(N / 1000)

print((remain)*1000 -N)

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

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

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

Solution (Python):
s = str(input())
if len(s) >= 3:
    n = [s[-3], s[-2], s[-1]]
if len(s) == 2:
    n = [s[-2], s[-1]]
if len(s) == 1:
    n = [s[0]]
n = ''.join(n)
n = int(n)
if n == 0:
    print(0)
else:
    print(1000 - n)

Solution (Python):


import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union































def main():
    Num = Union[int, float]
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    
    
    
    n = ii()
    if n % 1000 == 0:
        print(0)
    else:
        res = n % 1000
        print(1000 - res)



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())
amari = 0
while(N>0):
    N = N - 1000
N = -(N)
print(N)

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

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

Solution (Python):
price = int(input())
mult, res = divmod(price, 1000)
print(0 if res == 0 else 1000 - res)

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

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

Solution (Python):
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
if n % 1000 == 0:
    print(0)
    exit()
for i in range(1, 10001):
    if(0 < 1000*i-n):
        print(1000*i-n)
        exit()

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

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

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

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

Solution (Python):
N = int(input())
mn = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
for i in range(len(mn)):
    if mn[i] >= N:
        print(mn[i] - N)
        exit()

Solution (Python):
from math import gcd, sqrt, pi, floor, ceil
from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a

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

Solution (Python):
import sys
N=int(input())
i=0
for i in range(0,10001,1000):
    if i >= N:
        print(i-N)
        sys.exit()

Solution (Python):

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

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

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

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

if b == 0:
    ans = 0
else:
    ans = (a + 1) * 1000 - N

print(ans)

Solution (Python):
import sys

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

N = I()

ans = N // 1000
ans2 = N - (ans*1000)

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

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

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

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

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

change = 0

while N > 1000:
    N -= 1000

change = 1000 - N

print(change)

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

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

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

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

if 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 9000< n <=10000:
    print(10000-n)

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

print(1000*n-N)

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

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

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

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

print(chn)

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

print((m*1000) - n)

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

Solution (Python):
import math
n = int(input())
ans  =10**6
for i in range(1,math.ceil(n/1000)+1):
    x = n-(i*1000)
    if x<=0:
        ans = min(ans,abs(x))
print(ans)

Solution (Python):
n = int(input())
a = 0
for x in range(100):
    if n <= (x+1)*1000:
        a = ((x+1)*1000)-n
        break
print(a)

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

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

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

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
sum = int(input())
pay = 0
while sum > pay:
    pay += 1000
print(pay - sum)

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



if(n == 10000):
    print(0)
elif(n%1000 == 0):
    print(0)
else:  
    print(1000-n%1000)
'''
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
print(a)
'''

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

okane = 1000*(int(N/1000)+1)

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

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

if __name__ == "__main__":
    main()

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

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

syousuu = n / 1000
sen = math.ceil(syousuu)
print(sen * 1000 - n)

Solution (Python):
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    print(math.ceil(n/1000)*1000 - n)
    return 0

if __name__ == "__main__":
    solve()

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

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

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

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

x=1000-N

print(x)

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

Solution (Python):
import sys

def main():

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

if __name__ == "__main__":
    main()

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

senen = math.ceil(nedan / 1000) * 1000

print(senen - nedan)

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

if n>0 and n<1001:
    x=1000-n
if n>1000 and n<2001:
    x=2000-n
if n>2000 and n<3001:
    x=3000-n
if n>3000 and n<4001:
    x=4000-n
if n>4000 and n<5001:
    x=5000-n
if n>5000 and n<6001:
    x=6000-n
if n>6000 and n<7001:
    x=7000-n
if n>7000 and n<8001:
    x=8000-n
if n>8000 and n<9001:
    x=9000-n
if n>9000 and n<10001:
    x=10000-n

print(x)

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

for i in range(1000,10001,1000):
    if N <= i:
        print(i - N)
        break;

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

Solution (Python):
def main():
    N = int(input())
    if N < 1000:
        print(1000 - N)
        return
    N = str(N)
    N = N[-3] + N[-2] + N[-1]
    N = int(N)
    if N == 0:
        print(0)
        return
    
    print(1000 - N)
    
main()

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

Solution (Python):
N = input()
if int(N) >= 1000: 
    if int(''.join(N[-3:])) == 000:
        print(0)
    else:
        print(1000 - int(''.join(N[-3:])))

else:
    print(1000 - int(N))

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

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

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

c = n % 1000

if c == 0:
    s = 0
else:
    s = 1000 - c

print(s)

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

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

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

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

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

Solution (Python):
sum = int(input())
pay = 0
while sum > pay:
    pay += 1000
print(pay - sum)

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

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

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

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

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

k = N // 1000
m = N % 1000

if m == 0:
    ans = 0
else:
    ans = 1000 * (k + 1) - N

print(ans)

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

if mod == 0:
  print(0)
else:
  b = mod -1000
  c = int(abs(b))
 
  print(c)

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

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

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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

Solution (Python):
import sys;input = lambda : sys.stdin.readline()
n = int(input())
x=(n//1000)*1000 if n%1000==0 else (((n//1000)+1)*1000)
print(x-n)

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

count = 0
while p > count:
    count += 1000
print(count - p)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]





N = ii()

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

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

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

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

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

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

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

money = 1000
while money < N:
    money += 1000

print(money - N)

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

k = abs(N)
print(k)

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

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

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

A = a - N

print(A)

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

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

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

Solution (Python):
def INT():
    return int(input())

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

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

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

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

i = 1
while True:
    tmp = 1000 * i
    if tmp - n >= 0:
        print(tmp-n)
        exit()
    i += 1

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

a = t / 1000

if int(a) == a:
  a = int(a)
elif a>int(a):
  a = int(a) + 1
b = a * 1000

print(b-t)