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

Solution (Python):
N=int(input())
a=0
if N<1000:
    print(1000-N)
    exit()
else:
    while 1:
        if a*1000-N>=0:
            print(a*1000-N)
            exit()
        else:
            a+=1

Solution (Python):
N=int(input())
a=0
if N<1000:
    print(1000-N)
    exit()
else:
    while 1:
        if 0<=a*1000-N:
            print(a*1000-N)
            exit()
        else:
            a+=1

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

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

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

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

amari = n % 1000

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

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

amari = n % 1000

oturi = (1000 - amari) % 1000








print(oturi)

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





print((1000 - n % 1000) % 1000)

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

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

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

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

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):
print(-int(input()) % 1000)

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

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

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

change = 1000 - (price % 1000)
if change == 1000:
    change = 0

print(change)

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

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

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

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

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


print((1000 - (n % 1000)) % 1000)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())
counter = 0
while counter * 1000 < n:
    if counter * 1000 < n:
        counter += 1
if counter == 0:
    print(0)
else:
    print((counter*1000)-n)

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

Solution (Python):

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

    
    while n > 0:
        n -= 1000

    print(-n)

    
if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin,stdout
for _ in range(1):
    n=int(stdin.readline())
    nm=1000*(n//1000)
    if nm<n:nm+=1000
    print(nm-n)

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

if a % 1000 == 0:
  out = 0
else:
  out = 1000 - a % 1000

print(out)

Solution (Python):
N=int(input())
i=0
mai=1000
while i<11:
  if N <=mai:
    break
  else:
    mai+=1000
print(mai-N)

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

def fun(x):
    retorno = 0
    
    if x % 1000 != 0:
        while x > 1000:
            x -= 1000
        retorno = 1000 - x

    return retorno

print(fun(qtd))

Solution (Python):
n = int(input())
 
digit = len(str(n))
 
if digit < 4:
    answer = 1000 - n
else:
    three_digits = str(n)[-3:]
    if three_digits == '000':
        answer = 0
    else:
        answer = 1000 - int(three_digits)
print(answer)

Solution (Python):
N=int(input())
a=0
if N<1000:
    print(1000-N)
    exit()
else:
    while 1:
        if a*1000-N>=0:
            print(a*1000-N)
            exit()
        else:
            a+=1

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())

    pay = (N + 1000 - 1) // 1000 * 1000
    ans = pay - N
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
n=int(input())
for i in range(10):
  n=n-1000
  if n<=0:
    print(1000-(n+1000))
    sys.exit()

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

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

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

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

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

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

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

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

Solution (Python):



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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    print((100000 - ni()) % 1000)
    return

solve()

Solution (Python):

import math
n = int(input())

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

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

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

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

else:
    print(1000-(n%1000))

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

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

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

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

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

rem = money % 1000

oturi = 0
if rem != 0:
  oturi = 1000 - rem

print(oturi)

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

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

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

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

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

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

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

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

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

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

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

while N > i * 1000:
    i += 1

ans = i * 1000 - N
print(ans)

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

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

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

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

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

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

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

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

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

Solution (Python):

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

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

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

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

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

if __name__ == "__main__":
    main()

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

ans = (1000 - n%1000)%1000

print(ans)

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

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

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

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

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

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

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

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

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

print(0 if pay % 1000 == 0 and pay != 0 else 1000 - (pay % 1000))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

X = N%1000

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

Solution (Python):
N = int(open(0).read())
m = N % 1000
if m == 0:
    print(0)
else:
    print(1000 - m)

Solution (Python):

n = int(input())

print((1000 - (n%1000))% 1000)

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

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

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

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

while 0 < N:
    N -= 1000

print(abs(N))

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

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

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

Solution (Python):

def q1():
    N = int(input())
    if N % 1000 == 0:
        print(0)
        return
    print(1000 - N % 1000)


q1()

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

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

Solution (Python):


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

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

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

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

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

if N%1000 == 0:
  n = N//1000
else:
  n = N//1000 + 1

ans = 1000*n - N
print(ans)

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

while m < N:
    m += 1000
else:
    print(m-N)

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

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

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

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

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

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

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

Solution (Python):
import math

n = int(input())

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

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

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

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

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

Solution (Python):

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7


def ddprint(x):
  if DBG:
    print(x)

n = inn()
print((1000-n%1000)%1000)

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

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

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

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

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

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

Solution (Python):
def my_input():
    i = list(map(int, input().split()))
    if len(i) == 1:
        return i[0]
    return i


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

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

Solution (Python):
int = int(input())
y = 1000
for i in range(1,11):
    z = y*i
    if int <= z:
        o = z - int
        break;
    else:
        pass

print(o)

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

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

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

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

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

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

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

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

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):
import math
cost=int(input())
payment=math.ceil(cost/1000)*1000
print(payment-cost)

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

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

else:
   print(0)

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

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

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

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

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


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

Solution (Python):


price = int(input())
pay = 1000

while pay < price:
    pay += 1000
    

ans = pay - price
print(ans)

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

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

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

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

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

Solution (Python):

import math
N = int(input())

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

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

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

Solution (Python):
a=int(input())
r=1000
for i in range(10000000):
  if r>=a:
    break
  r=1000*i
print(r-a)

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

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

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

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

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):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())

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

Solution (Python):



def main():
    N = int(input())
    u = 1000
    print(((N+u-1)//u)*u-N)

if __name__ == '__main__':
    main()

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

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

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

k = 0
while k * 1000 < N:
    k += 1

ans = k * 1000 - N
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+999)//1000*1000 - N)

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

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

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

a=divmod(N,1000)

if a[1]==0:
    print(a[1])
else:
    print((a[0]+1)*1000-N)

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

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

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



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

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

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

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

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

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

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

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

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

x = 1000



while True:
    if amount == 0:
        x = 0
        break
    if x < amount:
        x += 1000
    else:
        break
 
print(x - amount)

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

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

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

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

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

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

Solution (Python):

N = int(input())
noguchi = [1000 * n for n in range(1, 11)]


print(min([ngc - N for ngc in noguchi if (ngc - N) >= 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())

while n > 0:
    n =  n - 1000

ans = -1 * n

print(ans)

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

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

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

n %= 1000

if n == 0:
    print(0)
else:
    print("{}".format(1000-n))

Solution (Python):
import sys


N = input()
    

N_in = int(N)

if N_in>10000 or N_in<0:
    print('error')
    sys.exit()

N = N_in/1000;

N_f = float(N)

N_i = int(N)


if (N_f - N_i) == 0:
    Ans = 0
    print(Ans)

else:
    N_i = N_i + 1
    Ans = N_i*1000 - N_in
    print(Ans)

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

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

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

n %= 1000

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

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

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

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

if money % 1000 == 0:
  print(0)
elif money < 1000:
  print(1000 - money)
else:
  print(1000 - (money % 1000))

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

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

Solution (Python):


def eval(N):
    while N >= 1000:
        N -= 1000

    if N == 0:
        return 0
    else:
        return 1000 - N


N = int(input())
print(eval(N))

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

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

ans = n%1000

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

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

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

Solution (Python):




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

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


if __name__ == "__main__":
    main()

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

while n > 1000:
  n -= 1000

print(1000 - n)

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

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

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

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

print(change)

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

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

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

sen = n // 1000
kei = n - sen*1000
if kei == 0:
    print(0)
else:
    print(1000-kei)

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

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

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

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

Solution (Python):
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n = ri()
    r = n % 1000
    if r == 0:
        print (r)
    else:
        print (1000 - r)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

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

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

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

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

Solution (Python):
















production = True

import sys, math, collections

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for i in range(multi)]
    else:
        next_line = sys.stdin.readline()[:-1]

        if input_format >= 10:
            use_list = False
            input_format = int(str(input_format)[-1])
        else: use_list = True

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = list(next_line)
        elif input_format == 4: formatted_input = list(map(int, list(next_line)))
        elif input_format == 5: formatted_input = next_line.split()
        else: formatted_input = [next_line]

        return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format = 0, newline = True):

    formatted_output = ""

    if output_format == 0: formatted_output = str(output_line)
    elif output_format == 1: formatted_output = " ".join(map(str, output_line))
    elif output_format == 2: formatted_output = "\n".join(map(str, output_line))

    print(formatted_output, end = "\n" if newline else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate

ter = lambda a, b, c: b if a else c

def mapl(iterable, format = 0):
    
    if format == 0: return list(map(int, iterable))
    elif format == 1: return list(map(str, iterable))
    elif format == 2: return list(map(list, iterable))





def solve():

    n = input(11)

    b = math.ceil((n) / 1000) * 1000

    log(b)
    out(b - n)
    return



solve()

Solution (Python):
price = int(input())
thousand = -(-price//1000)
tsuri = 1000*thousand-price
print(tsuri)

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

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

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

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

amari = N%1000


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

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

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

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

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

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

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

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

A()

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

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

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