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

Solution (Python):

import 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 math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[j - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] =  j
    return pi

def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else '0' * (length - len(y)) + y

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

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

Solution (Python):
def solver(N):
    for i in range(1,11):
        charge = 1000 * i - N
        if charge >= 0 and charge < 1000:
            return charge

print(solver(int(input())))

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

i = 0
x = 0
while x<X:
  x = i*1000
  i+=1
print (x-X)

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

syo = N//1000

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

Solution (Python):
import math

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

print(tmp - n)

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

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

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

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

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

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

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

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

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

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

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

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

amari = n % 1000

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

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

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

m = 0
for i in range(12):
    if n > 1000*i:
        m = i
        
ans = 1000*(m+1) - n
print(ans)

Solution (Python):
n = int(input())
money = 0
while n > money:
    money += 1000

print(money-n)

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

for i in range(n) :
    temp=1000*(i+1)-n
    if  temp>= 0 :
        print(temp)
        break

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

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

if __name__ == "__main__":
    solve()

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

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

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

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

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

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

x = 1000 - n
print(x)

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int):
    answer = 1000 - (N % 1000)
    if answer == 1000:
        answer = 0
    return answer

def main():
    N = int(input())  
    answer = solve(N)
    print(answer)

if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):

N=input()
if len(N) >= 4:
    N_3=N[-3:]
    ans=1000-int(N_3) if int(N_3) !=0 else 0
else:
    ans=1000-int(N)
print(ans)

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

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

Solution (Python):
import math
N = float(input())
if N % 1000 == 0:
    print(0)
else:
    thousand_total =  math.ceil((N + 1) / 1000) * 1000
    print (int(thousand_total - N))

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

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

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

amari = n%1000

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

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

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

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

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

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

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

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

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

Solution (Python):
import math

beer_price = int(input())
bill = math.ceil(beer_price / 1000) * 1000
change = bill - beer_price
print(change)

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

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

i = 1
while True:
  M = 1000*i
  if M >= N:
    break
  
  i += 1
    
ans = M-N

print(ans)

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

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

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

Solution (Python):



def next_line():
    return input()


def next_int():
    return int(input())


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


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    print((10000 - next_int()) % 1000)


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

Solution (Python):
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
input=sys.stdin.readline


mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())









n=inin()
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
  ans = 1000*(x + 1) - n
  print(ans)

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

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

elif N % 1000 == 0:
	print(0)

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

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

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

Solution (Python):
import sys
import numpy as np  

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


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

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

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

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

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

i = 0
while 1000 * i < N:
    i += 1
change = 1000 * i - N

print(change)

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

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

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


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

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

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

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

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

while N>1000:
    N=N-1000
        

x=1000-N

print(x)

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

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

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

noguchi = (Nin // 1000)
if (Nin % 1000):
    noguchi += 1

print(noguchi*1000 - Nin)

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

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

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

while True:
    if n % 1000 == 0:
        break
    n += 1
    x += 1

print(x)

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

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

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

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

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

a = N%1000
if a == 0 :
    ans = 0
else:
    ans = 1000 - a

print(ans)

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

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

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

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

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

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

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

Solution (Python):



n=int(input())
res=n//1000
if res*1000==n:
    print(0)
else:
    n=n-res*1000
    print(1000-n)

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

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

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

print(-(N%-1000))

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

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

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline

def inp():
    return(int(input()))



n = inp()

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

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

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

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

Solution (Python):
n=int(input())
if n%1000==0:
    print(0)
else:
    i=n//1000
    print((i+1)*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())
i = 0
while True:
    t = 1000*i
    if t >= n:
        p = t - n
        break
    i +=1
print(p)

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

Solution (Python):
N = int(input().rstrip())
num = 0

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

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

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

c = n % 1000

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

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

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

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

Solution (Python):

"""
Created on Fri Aug  7 01:24:25 2020

@author: saito
"""






N = int(input())


answer = 1000-((N-1)%1000+1)


print(answer)

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

change = 0
mod_change = price % 1000
if mod_change != 0:
    change = 1000 - mod_change

print(change)

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

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

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

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

abc173a_payment()

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


if __name__ == '__main__':
    main()

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

Solution (Python):
i = int(input().strip())
if i % 1000 == 0:
    print('0')
else:
    print((i // 1000 + 1) * 1000 - i)

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

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

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((100000000 - ni()) % 1000)
    return

solve()

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((100000000 - ni()) % 1000)
    return

solve()

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

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

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

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

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

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

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

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

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

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

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

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

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


print((1000 - N) % 1000)

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

a = 10000

ans = (a - n) % 1000

print(ans)

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

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

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

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

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

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

Solution (Python):
n = int(input())
rounded = round(n, -3)
if rounded < n:
  rounded += 1000
print(rounded - n)

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

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

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

a = price % 1000
c = 1000 - a

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

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

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

ct = 0
for ct in range(1,11):
    pay = 1000 * ct
    if  pay >= N:
        tsuri = pay - N
        break

print(tsuri)

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

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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

for i in range(1, 12):
    if 1000*i-N>=0:
        print(1000*i-N)
        sys.exit()

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

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

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

Solution (Python):
s = input()
n = int(s)
if(n < 1000):
    print(1000 - n)
elif(s[-3:] == "000"):
    print(0)
else:
    print(1000 - int(s[-3:]))

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

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

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

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

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

while(True) : 
    if N >= 1000 : 
        N -= 1000
    elif N == 0 : 
        print(N)
        exit()
    else : 
        print(1000-N)
        exit()

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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


def main():
    solve()


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
for i in range(0,10001,1000):
  if i - n >= 0:
    print(i - n)
    exit()
  else:
    continue

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

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

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

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

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

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

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

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

for i in range(10):
 if N>1000:
  N-=1000
 if N<1000:
  break

print(1000-N)

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

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

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

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

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

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

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

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

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

print(ans)

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

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

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

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

x=1000-(n%1000)

if (n%1000)==0:
    print(0)
else :
    print('{}'.format(x))

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

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

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

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

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

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

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

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

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

Solution (Python):
k = int(input())
n  =1000
t  =[]

for i in range(1,11):
	if n*i-k>=0:
		t.append(n*i-k)

print(min(t))

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

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

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

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

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

print(ans)

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

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

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

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

Solution (Python):

N = int(input())

out = 1000 - (N % 1000)
if out == 1000: out = 0

print(out)

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

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

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

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

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

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

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

Solution (Python):

N = int(input())
print((10000 - N) % 1000)

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

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

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

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

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

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

Solution (Python):
n=int(input())
if n<1000:
    print(1000-n)
else:
    str1=""
    k=n//1000
    l=len(str(n))-len(str(k))
    str1=str(k)+'0'*l
    if str1==str(n):
        print(0)
    else:
        p=int(str1)+1000
        print(p-n)

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

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

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

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

print(ans)

Solution (Python):
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y

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

Solution (Python):
n=input()
t=len(n)
if t<4:
  print(1000-int(n))
else:
  k=int(n[0])
  if int(n)>k*10**(t-1):
    print((k+1)*1000-int(n))
  else:
    print(0)

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

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

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

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

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

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

Solution (Python):
'''
Date         : 2020-08-10 14:53:47
Author       : ssyze
Description  : 
'''
n = int(input())
print((n + 999)//1000 * 1000 - n)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

if N%1000 == 0:
    div=N//1000
else:
    div=(N//1000)+1

print(abs(N-(div*1000)))

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

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

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