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 sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 1000 - N
    while ans < 0:
        ans += 1000
    print(ans)




main()

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

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


if __name__=='__main__':
    t=1
    for _ in range(t):
        solve()

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

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

Solution (Python):
import sys
from math import ceil
input=sys.stdin.readline
_lii=lambda :list(map(int, input().strip('\n').split()))
_i=lambda :input().strip('\n')
res=[]

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

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

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

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

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

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

Solution (Python):
N = int(input())
for i in range(10):
    if N <= (i+1)*1000:
        print((i+1)*1000-N)
        exit()

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

Solution (Python):

import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()

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

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

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

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    x = N % 1000
    print(1000 - x if x != 0 else 0)

if __name__ == '__main__':
    main()

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

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

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

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

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

y=x%1000

if y==0:
  y=1000

print(1000-y)

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

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


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Solution (Python):

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

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

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

Solution (Python):



import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf



import math

import bisect


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

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

b = a% 1000

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

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

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

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

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

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

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


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

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

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

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

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

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

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

print(ans)

Solution (Python):


import sys

input = iter(sys.stdin.read().splitlines()).__next__

sys.setrecursionlimit(10000)

N = int(input())

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

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

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

m = 1000
while True:
  if m >= n:
    m -= n
    break
  m += 1000
  
print(m)

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

Solution (Python):
import math

N = int(input())

ans = math.ceil(N / 1000)

print(ans * 1000 - N)

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

main()

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

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

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

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

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

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








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

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

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

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

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

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

w = N // 1000
v = N % 1000
if v != 0:
    w += 1

print(w * 1000 - N)

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

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

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

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

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

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


if __name__ == '__main__':
    main()

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

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math
from collections import deque
import itertools
import heapq

from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint




def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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



if __name__ == "__main__":

    main()

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    k = n // 1000
    if n % 1000:
        k+=1
    print(1000*(k) -n)

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

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

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

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

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

print(ans)

Solution (Python):
n=int(input())
now=1000
for i in range(11):
  if now<n:
    now+=1000
  else:
    print(now-n)
    break

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

Solution (Python):


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

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

n = N % 1000

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

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

Solution (Python):

N=int(input())
turi=(N//1000)*1000-N
if turi<0: turi+=1000
print(turi)

Solution (Python):
import sys

n = int(input())
for i in range(10000):
    if (i * 1000 - n >= 0):
        print(i * 1000 - n)
        sys.exit()

Solution (Python):
if __name__ == '__main__':
    n = int(input().strip())

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

Solution (Python):
from sys  import stdin,stdout

import bisect
import math
def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
            n=n-1
        else:
            a=(a*a)
            n=n>>1
    return r
    
def solve():
    n=inp()
    a=math.ceil(n/1000)
    print(1000*a-n)




tc=1

for _ in range(tc):
    solve()

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

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    n = 1
    while True:
        if n * 1000 >= N:
            print((n * 1000) - N)
            exit()
        else:
            n += 1


if __name__ == '__main__':
    main()

Solution (Python):
a=input()[-3:]
a=int(a)

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

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    print((1000 - (n % 1000)) % 1000)




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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
n = Ii()
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))

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

a=N%1000

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

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

Solution (Python):
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,heapq
start_time = time.time()



def solve():
    n = inp()
    print(math.ceil(n / 1000) * 1000 - n)
    


 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 

def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    b = [[0] * len(a) for i in range(len(a))]
    for i in range(len(a)): 
        for j in range(len(a)): 
            b[i][j] = a[j][i]
    return(b)


        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
    
main()

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
res = (N//1000)*1000
if N%1000:
    res += 1000
print(res - N)

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

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

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

Solution (Python):
N = int(input())
Ans = 1000 - (N % 1000)
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):
import sys












stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    
    
    
    
    
    
    if n%1000 == 0:
        print(0)
    else:
        print(1000 - (n%1000))

if __name__ == '__main__':
    solve()

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

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

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

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

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

Solution (Python):
def main():
    n = int(input())
    p = 1000
    while p < n:
        p += 1000
    print(p - n)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)

    print((1000 - n) % 1000)


if __name__ == "__main__":
    main()

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

Solution (Python):
from sys import stdin
n = int(input())
if not n%1000:
    print(0)
else:
    print(1000-n%1000)

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

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

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

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

N = int(input())

k = N % 1000

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

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

Solution (Python):
N=int(input())
for i in range(100):
    if 1000*i<N<=1000*(i+1):
        a=i+1
        break

print(1000*(i+1)-N)

Solution (Python):

import sys


def solve(N: int):
    k = N % 1000
    if k != 0:
        print(1000-k)
    else:
        print(0)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):


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

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

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

import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a=ii()
b=math.ceil(a/1000)
print(b*1000-a)

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

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

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

Solution (Python):




from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n = ii1()
count = ceil(n / 1000)
print(count * 1000 - n)

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

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

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

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

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():

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

resolve()

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

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

num=1000-n

while num<0:
    num+=1000

print(num)

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

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

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

Solution (Python):
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    n = ii()
    if n%1000 == 0:
        print(0)
    else:
        print(1000 - n%1000)
    return

main()

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

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

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

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

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

Solution (Python):
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

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

    print(abs(N))

if __name__ == '__main__':
    main()

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


n=int(input())


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

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

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

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

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

ans = (n + 1000 - 1) // 1000 * 1000 - n
print(ans)

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

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

print((10000-N)%1000)

Solution (Python):
n = int(input())
i = 0
while i < n:
    i += 1000

print(i-n)

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

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

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

ans = -N
while ans < 0:
    ans += 1000

print(ans)

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

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

x = 0
while x < N:
  x += 1000
  
print(x - N)

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

Solution (Python):
n = int(input())
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):
import math


def _run(n):
    print((math.ceil(n / 1000) * 1000) - n)


def _main():
    N = int(input())
    _run(N)


if __name__ == "__main__":
    _main()

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

Solution (Python):
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

n = IN()
a = 0

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

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

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

Solution (Python):



N = int(input())

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

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

Solution (Python):
n = int(input())
for i in range(100):
    n -= 1000
    if n <= 0:
        break
print(abs(n))

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

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

print(1000 - n if n else 0)

Solution (Python):
import math

n=int(input())
i=1000
while i<n:
        i+=1000
print(i-n)

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

Solution (Python):
N = int(input())
if N%1000:
  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):
N = int(input())
for i in range(11):
    if 1000 * i >= N:
        print(1000 * i - N)
        exit()

Solution (Python):
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
n = int(input())




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

print(a)

Solution (Python):


n = int(input())

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

else:
    print((a+1)*1000 - n)

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

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


if __name__ == '__main__':
    print(solve())