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

count = 1

while True:
    if(1000 * count >= N):
        break
    count = count + 1

print(1000 * count - N)

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

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

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

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

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

print(1000*m -n)

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

while N * 1000 - Y <0:
    N += 1

print(N * 1000 - Y)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Ans = (P * 1000) - N
print(Ans)

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

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

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

Solution (Python):
N=int(input())
if N%1000!=0:
    print(((N//1000)+1)*1000-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):
def Qa():
    n = int(input())
    c = n % 1000
    if c != 0:
        c = 1000 - c
    print(c)


if __name__ == '__main__':
    Qa()

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

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

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

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

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

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

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

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

while True:
  if N <= M:
    print(M-N)
    break
  else:
    M += 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):
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):
print(-int(input())%1000)

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

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

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

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

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

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

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

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

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

Solution (Python):
n = input()

money = 0
if int(n)%1000 == 0:
    print(0)
elif 1000 > int(n):
    ans = 1000 - int(n)
    print(ans)
else:
    money = (int(n[:-3]) + 1)*1000
    ans = money - int(n)
    print(ans)

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

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

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

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

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

x = N % 1000

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

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

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

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

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

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

print((1000 - n%1000))

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

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

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

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

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

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

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

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

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

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

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

y = (10000 - x) % 1000

print(y)

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

sum = 0
while sum < n:
  sum += 1000
print(sum - n)

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

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

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

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

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

print(round_n-n)

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

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

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

Solution (Python):

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

Solution (Python):
def solve():
    n = int(input())
    print((1000 - n%1000)%1000)
if __name__=='__main__':
    solve()

Solution (Python):
def solve():
    n = int(input())
    print((1000 - n%1000)%1000)
if __name__=='__main__':
    solve()

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

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

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

a = 0

while n > 1000*a:
    a += 1

print(1000*a - n)

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

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

    print((10000 - N) % 1000)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
c=0
while n > 1000*c:
  c +=1

print(1000*c-n)

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]








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

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

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

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

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

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

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

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

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

Solution (Python):
import math

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

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

Solution (Python):

N = int(input())

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

Solution (Python):


N = int(input())

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

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

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

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

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

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

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

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

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[i - 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


for _ in range(int(input()) if not True else 1):
    n = int(input())
    
    
    
    
    
    
    print(ceil(n/1000)*1000-n)

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

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

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

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

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

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

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):
a = int(input(""))
if a <= 1000:
    print(1000-a)
elif a <= 2000:
    print(2000-a)
elif a <= 3000:
    print(3000-a)
elif a <= 4000:
    print(4000-a)
elif a <= 5000:
    print(5000-a)
elif a <= 6000:
    print(6000-a)
elif a <= 7000:
    print(7000-a)
elif a <= 8000:
    print(8000-a)
elif a <= 9000:
    print(9000-a)
else:
    print(10000-a)

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

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

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

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

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

Solution (Python):

N = int(input())


ans = N
while ans > 0:
    ans -= 1000

ans = -ans


print(ans)

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

a=n%1000

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

    print(1000-a)

Solution (Python):
a = int(input(""))
if 1000 >= a:
    print(1000 - a)
elif 2000 >= a > 1000:
    print(2000 - a)
elif 3000 >= a > 2000:
    print(3000 - a)
elif 4000 >= a > 3000:
    print(4000 - a)
elif 5000 >= a > 4000:
    print(5000 - a)
elif 6000 >= a > 5000:
    print(6000 - a)
elif 7000 >= a > 6000:
    print(7000 - a)
elif 8000 >= a > 7000:
    print(8000 - a)
elif 9000 >= a > 8000:
    print(9000 - a)
else:
    print(10000 - a)

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

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

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

print(change)

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

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

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

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

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

print(1000 - mod if mod else 0)

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

Solution (Python):

N = int(input())

rest = N%1000
if rest == 0:
    print(f"{0}")
else:
    print(f"{1000-rest}")

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())

k = n
a = 0

while(n > 0):
  
  n = n - 1000
  a = a + 1000
  
print(a - k)

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

Solution (Python):
import sys
n=int(next(sys.stdin))
print((n+999)//1000*1000-n)

Solution (Python):
import sys
n=int(next(sys.stdin))
r=n%1000
print(1000-r if r>0 else 0)

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

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

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

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

print(ans)

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

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

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

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

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

    ans = - N % 1000
    if ans < 0:
        ans += 1000

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N = input()

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

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

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

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

a = n % 1000
a = 1000 - a
a = a % 1000

print(a)

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

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

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

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

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

print((1000 - money % 1000) % 1000)

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

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

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

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

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

Solution (Python):
a = int(input().rstrip())
n = [i for i in range(1,11) if(a <=i *1000)]
print((min(n)*1000) - a)

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

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

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

Solution (Python):

if __name__ == '__main__':
    n = int(input())
    res = 1000 - n % 1000
    if res == 1000:
        res = 0
    print(res)

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

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

a = N % 1000

ans = 0
if a > 0 :
 ans = 1000 - a 
print(ans)

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

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

if n < 0:
    print(-n)
elif n == 0:
    print(n)

Solution (Python):

N=int(input())
a=int(N/1000)
otsuri=(a+1)*1000-N
if otsuri==1000:
    otsuri=0
print(otsuri)

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

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

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

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

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

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

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

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

fee = fee % 1000
pay = 1000
if fee == 0: pay = 0
print(pay - fee)

Solution (Python):
import sys
import numpy as np
from math import ceil

def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(Ss())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])

n = I()
print(ceil(n / 1000) * 1000 - n)

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

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

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

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

Solution (Python):
import math

N = int(input())

q = N / 10**3
pay = math.ceil(q) * 10**3

print(pay - N)

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

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

Solution (Python):
def solve(string):
    return str((1000 - (int(string) % 1000)) % 1000)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

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

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

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

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

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

Solution (Python):
N=int(input())
S=str(N)
s = ""
if N <1000:
    ans = 1000 - N
    print(ans)
    exit()
for i in range(3):
    s = S[len(S)-1-i] + s

n = int(s)
ans = 1000 - n
if ans == 1000:
    ans = 0

print(ans)

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())
i = N // 1000
j = i*1000
if i == 0 or j != N:
    i = i + 1
    j = i * 1000
print(j - N)

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

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

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

print(ans)

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

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

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

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

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

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

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

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

print((total)*1000-n)

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

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

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

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

Solution (Python):

n = int(input())
n2 = str(n)[-3:]
if int(n2) == 0:
    print(0)
else:
    ans = 1000 - int(n2)
    print(ans)

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

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

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

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

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

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

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

while x > 0:
  x -= 1000
  
print(x*-1)

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

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

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

print(ans)

Solution (Python):
import sys
input=sys.stdin.buffer.readline
import os
from math import*

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

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

print(redual)

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

if N % 1000 == 0:
    print(0)
else:
    div = N // 1000
    ans = (div+1)*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())
res = n % 1000
if (res > 0):
  res = 1000 - res
print(res)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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)

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

Solution (Python):
import datetime
import string
import re
import math

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

print(1000 - N)

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

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

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

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

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

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

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