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 i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

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

print(otsuri)

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

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

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

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

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

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

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

while N > 1000:
    N = N - 1000

print(1000 - N)

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

tmp = N % 1000

result = 1000 - tmp

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

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

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

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

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

print(ans)

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

sen = int((N-0.1)//1000)

hyakuika = N-sen*1000

ans = int(1000 - hyakuika)

print(ans)

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

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

Solution (Python):
import math

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

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

mod = N%1000

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    r = N % 1000
    ans = 0
    if r % 1000 != 0:
        ans = 1000 - r
    print(ans)

if __name__ == '__main__':
    solve()

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

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

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

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

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

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

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

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

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

sum =0
cnt =1

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

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

Solution (Python):


a = int(input())
b = a // 1000

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

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

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

if n%1000==0:
    print(0)
    exit()
n-=1000*(n//1000)

print(1000-n)

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

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

else:
    b = 1000 - a
    print(b)

Solution (Python):


price=int(input())

if(price%1000==0):
    change=0
else:
    for i in range(11):
        change=1000*i-price
        if(change>0):
            break
        
print(change)

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

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

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

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

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

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

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

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

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

while(c<a):
  c+=1000

print(c-a)

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())
ini = 1000
diff = 0
while True:
    if ini-n>=0:
        break
    ini += 1000
print(ini-n)

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

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

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

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

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

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

    
if '__main__' == __name__:
    resolve()

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

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

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

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

m = n % 1000

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

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

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(str(1000-b))

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Solution (Python):

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

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

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

Solution (Python):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    for i in range(1000):
        if (n+ i)%1000 == 0:
            print(i)


if __name__ == '__main__':
    main()

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

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()

_, c = divmod(N, 1000)
if c == 0:
    print(0)
else:
    print(1000 - c)

Solution (Python):



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

N = int(input())

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

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

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

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

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

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

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

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

Solution (Python):
n=int(input())
money=1000
while(1):
    if n<=money:
        break
    money+=1000
print(money-n)

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

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

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())
while True:
  n -= 1000
  if n <= 0:
    print(abs(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())

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

main()

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

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

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

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

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

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

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

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

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

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

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

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

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











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

for i in range(11):
    if n > 1000*i and n < 1000*(i+1):
        print(1000*(i+1)-n)
        exit()
print(0)

Solution (Python):
n=input()

a=1000-int(n[-3:])
if a == 1000 :
    print(0)
else:
    print(1000-int(n[-3:]))

Solution (Python):



import sys


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


def resolve():
    n = int(input().rstrip())
    cnt = 0
    while True:
        cnt += 1
        remain = n - (cnt*1000)
        if remain <= 0:
            change = cnt*1000 - n
            break


    print(change)


if __name__ == "__main__":
    resolve()

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

print(-n%1000)

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

Solution (Python):
def resolve():
    c = int(input())

    if c % 10**3 != 0:
        print(1000 - c % 10**3)
    else:
        print(0)

resolve()

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

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

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

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

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

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

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

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

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

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

if a % 1000 == 0:
    print("0")
    quit()

while a > 1000:
    a -= 1000
    if a < 1000:
        break
print(1000-a)

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

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

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

Solution (Python):
n = int(input())
for i in range(1000, 10001, 1000):
    if n <= i:
        print(i-n)
        break

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

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

print(ans)

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

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

Solution (Python):













from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect



MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): 
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): 
    return reduce(math.gcd, numbers)

def combination(m,n): 
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): 
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    a = int(stdin.readline().rstrip())
    amari = a % 1000
    if amari == 0:
        print(0)
    else:
        print(1000-amari)
    
main()

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

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

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

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

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

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

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

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


ch = 1000 - (N % 1000)

if ch != 1000:
    print(ch)
else:
    print(0)

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

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




n = int(input())

a = n // 1000
if n % 1000 > 0 :
    a = a + 1


print(a*1000 - n)

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

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

if __name__ == "__main__":
    solve()

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

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

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

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

r, q = divmod(N, 1000)

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

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

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

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

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

if __name__ == '__main__':
    main()

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

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

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

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

else:
    print(1000-n%1000)

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

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

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

print(abs(n))

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

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

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

if n % 1000 == 0:
    print(0)
else:
    change = n // 1000

    print( 1000 - (n - change * 1000))

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    a=(n+999)//1000
    print(a*1000-n)

main()

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

a = (n//1000+1)*1000-n

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

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

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

if n%1000 == 0:
  a = n // 1000
else:
  a = (n // 1000) +1

print((a *1000) - n)

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

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

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

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

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

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

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

Solution (Python):

price = int(input())
if price < 1000: print(1000-price)
else:
    a, b = divmod(price, 1000)
    if b == 0: print("0")
    else: print(1000-b)

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

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

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

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

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

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

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

resolve()

Solution (Python):

from collections import deque




import os
import sys
from io import BytesIO, IOBase




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
from bisect import bisect_left as bl
from math import log2,ceil
from heapq import heappush, heappop
from itertools import permutations 
def main():
    
        n = int(input())
        x = (n+1000)//1000*1000-n
        if x==1000:
            print(0)
        else:
            print(x)

            

        


        
        






if __name__ == "__main__":
    main()

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

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

count = (n // 1000)
money = count * 1000

if money < n:
  print((count+1) * 1000 -n)
else:
  print((count) * 1000 -n)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False



def main():
    N = I()

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

ha =  (N // 1000 + 1) * 1000 - N 

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

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

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

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

while n - 1000 >= 0:
    n -= 1000
if n % 1000 == 0:
    print(0)
else:
    print(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())
M = 10000 - N
M = str(M)
M = M[-3:]
M = int(M)
print(M)

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

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

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

Solution (Python):
k=1
N=int(input())
while(1):
    if(k*1000>=N):
        break
    else:
        k+=1
ans=1000*k-N

print(ans)

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

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

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

reminder = N % 1000

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

Solution (Python):
n= int(input())
if 1<=n<=1000:print(1000-n)
if 1001<=n<=2000:print(2000-n)
if 2001<=n<=3000:print(3000-n)
if 3001<=n<=4000:print(4000-n)
if 4001<=n<=5000:print(5000-n)
if 5001<=n<=6000:print(6000-n)
if 6001<=n<=7000:print(7000-n)
if 7001<=n<=8000:print(8000-n)
if 8001<=n<=9000:print(9000-n)
if 9001<=n<=10000:print(10000-n)

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

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

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

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

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

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

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

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

ans = 1000-(N%1000)

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

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

a=N//1000

ans=1000-(N-a*1000)

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

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

Solution (Python):
n = int(input())
x = 0
for i in range(11) :
    if 1000*i>=n and x == 0:
        x = i

print(1000*x-n)

Solution (Python):

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

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

N=int(input().rstrip('\n'))
n = N%1000
if n==0:
  print(n)
else:
  print(1000-n)

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