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

cnt = N // 1000 + 1 if N % 1000 != 0 else N // 1000
print(1000*cnt - 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(int(N / 1000 + 1) * 1000 - N )

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

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

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

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

Solution (Python):


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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys

input = sys.stdin.readline


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


def str_array():
    return input().strip().split()


def lower_letters():
    lowercase = [chr(i) for i in range(97, 97+26)]
    return lowercase

def how_frequent(lis):
	last = None
	count = []
	each = 1
	for i in range(len(lis)):
		if last != None:
			last = lis[i-1]
		if last == lis[i]:
			each += 1
		else:
			count.append(each)
			each = 0
		last = lis[i]
	return max(count)


def upper_letters():
    uppercase = [chr(i) for i in range(65, 65+26)]
    return uppercase


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

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

Solution (Python):

import sys
input = sys.stdin.readline


def ceil(x):
    if x != int(x):
        x = int(x) + 1;
    return x;
    

def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp


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


def nCr(n, k): 
    if(k > n - k): 
        k = n - k 
    res = 1
    for i in range(k): 
        res = res * (n - i) 
        res = res / (i + 1) 
    return int(res) 


def upper_bound(a, x, lo=0, hi = None):
    if hi == None:
        hi = len(a);
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo


def primefs(n):
    
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    
    
    return primes


def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 


def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b









def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;




def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x


def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime


MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    




def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    
    


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

def str_array():
    return input().strip().split();


MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');



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

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

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

Solution (Python):
n=input()
N=int(n)
if 1<=N and N<1000:
  ch1=1000-N
  print(ch1)
else:
  if int(n[3])==0 and int(n[2])==0 and int(n[1])==0 :
    print(0)
  else:
    ch2=1000*(int(n[0])+1)-N
    print(ch2)

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

Solution (Python):
n = int(input())
pay = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]

for p in pay:
  if (p - n) < 1000 and (p - n) >= 0:
    print(p-n)
    exit()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    N = ini()
    d = N % 1000
    if d == 0:
        return 0
    return 1000 - d


print(solve())

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

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

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

mod = N % 1000

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

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

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

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

th = (999 + n) // 1000

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

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

Solution (Python):
n = int(input())
a = int(n/1000 +1)

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

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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N = INT()

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

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

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

print(-N%1000)

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

while N > 0:
    N -= 1000
print(-N)

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

Solution (Python):

from collections import defaultdict
import math,sys


def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
	

def get_array():
	l=list(map(int, input().split()))
	return l
def sod(n):
	n,c=str(n),0
	for i in n:	
		c+=int(i)
	return c	

def main():
	
	n=int(input())
	ans=1000
	
	for i in range(100000):
		if(ans>=n):
			print(ans-n)
			
			break
		else:	
			ans+=1000
	
		'''n,x=map(int, input().split())
		l=list(map(int, input().split()))
		l.sort()
		for i in range(len(l)):
			if(2*l[i]>x):
				ind=i
				break
		
		l=l[ind:]+l[:ind]
		print(l)
		cures=len(l)
		i,ans=0,0
		print('h')
		while(cures>0):
			print("nz")
			if(x>=l[i]):
				cures-=1
				x=2*l[i]
				i+=1
			else:
				temp=l[i]
				l[i]=l[i]-x

				l[i]=min(2*l[i],temp)
			ans+=1
		print(ans)'''



		







		
		
		











		








if __name__ == '__main__':
    main()

Solution (Python):


n=int(input())



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

Solution (Python):

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()

ans = -N % 1000
print(ans)

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

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

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

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

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

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

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

Solution (Python):
n=int(input())
ans=1000
if n<100:
    print(abs(n-ans))
    exit()
else:
    ans=1000
    while(n>=ans):
        if ans==n:
            break
        elif ans>n:
            break
        else:
            ans+=1000
print(abs(n-ans))

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

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

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

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

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

Solution (Python):
num=input()
if 1<=int(num)<=10000:
    if int(num)<=1000:
        change=1000-int(num)
    else:
        array_1=list(num)
        array_1=array_1[-4:]
        a=''.join(array_1)
        b=int(array_1[-4])+1
        pay=b*1000
        change=pay-int(a)
        if array_1[-1]=="0" and array_1[-2]=="0" and array_1[-3]=="0":
            change=0
    print(change)

Solution (Python):
import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations 
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 

if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def li():
	return [int(x) for x in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def gi():	
	return [x for x in input().split()]
def fi():
	return int(input())
def swap(a,i,j):
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())	
def gh():
	sys.stdout.flush()
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def bo(i):
	return ord(i)-ord('a')
		


tt=1


while tt>0:
	tt-=1
	n=fi()
	p=n//1000*1000
	if p<n:
		p+=1000
	print(p-n)

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

Solution (Python):
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
import heapq 
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))

def dict(a):
    d={}
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d

def main():
    try:
        n=I()
        temp=(math.ceil(n/1000)*1000)-n
        print(temp)
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    
    for _ in range(1):main()

Solution (Python):
import sys
import math
import collections
import heapq

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


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


if __name__ == '__main__':
    

    
    t = 1

    for ti in range(1, t + 1):
        n = int(input())

        for i in range(1000, 11000, 1000):
            if i >= n:
                print(i - n)
                break

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

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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

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

    change = -N % 1000
    print(change)


if __name__ == '__main__':
    main()

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

Solution (Python):

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    
    ans = 10 ** 5
    for i in range(10, 0, -1):
        a = 1000 * i
        if a < N:
            break
        ans = a - N
    print(ans)


if __name__ == '__main__':
    solve()

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

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

Solution (Python):
import math

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

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

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

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

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

Solution (Python):
from sys import stdin, stdout
import sys
INF=1e11
import bisect
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
from collections import defaultdict 
import math

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

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

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

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

    change = (N + 999) // 1000 * 1000 - N
    print(change)


if __name__ == '__main__':
    main()

Solution (Python):

def resolve():
    N = int(input())
    if N % 1000 == 0:
        return print(0)
    else:
        d = N%1000
        print(1000 - d)

if __name__ == "__main__":
    resolve()

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

syoji = 1000


while syoji < enn:
    syoji = syoji +1000

print(syoji-enn)

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

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

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

Solution (Python):
import math

def main(a):
    return int(math.ceil(a/1000.0)*1000-a)

if __name__ == "__main__":
    a = int(input())
    print(int(main(a)))

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

Solution (Python):


N = int(input())
1 <= N <= 10000

if N % 1000 == 0:
 print(0)
else:
  sen = N//1000
  sen2 = sen*1000
  atai = N-sen2
  atai2 = 1000-atai
  print(atai2)

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

A = (N + 1000 - 1) // 1000
print(A*1000 - N)

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

Solution (Python):


def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数（1 <= N <= 10000）
    """
    
    ans = (1000 - (N % 1000)) % 1000

    
    print(ans)


if __name__ == "__main__":
    
    N = get_input()

    
    main(N)

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

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

Solution (Python):
n=int(input())
for i in range(1,11):
  if n<=i*1000:
    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())
x = (N+1000-1)//1000
ans = 1000*x - N
print(ans)

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n=int(input())
ans=1000
if n<100:
    print(abs(n-ans))
    exit()
else:
    ans=1000
    while(n>ans):
        if ans==n:
            break
        elif ans>n:
            break
        else:
            ans+=1000
print(abs(n-ans))

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

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()

print(999-(N-1)%1000)

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

Solution (Python):
N=input()
if len(N)>3:
    i=(int(N[:-3])+1)*1000
else:
    i=1000

j=i-int(N)

if j>999:
  print(0)
else:
  print(j)

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

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

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

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

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


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

Solution (Python):
t=int(input())
if t>=10000:
    t%=10000
    if t==0:
        print(t)
    else:
        print(1000-t)
else:
    t%=1000
    if t==0:
        print(t)
    else:
        print(1000-t)
import math

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

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

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

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

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

while N > 0:
    N -= 1000

print(-N)

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

Solution (Python):

import sys


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

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

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

Solution (Python):
print((1000 - int(input()) % 1000) % 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):
from collections import deque
import math
import os
import random
import re
import sys



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

'''
if __name__ == '__main__':
    main()
'''

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

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

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

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

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

Solution (Python):
import sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    print((1000 - int(input()) % 1000) % 1000)
resolve()

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

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

Solution (Python):
N = int(input())
n = 0
while True:
    if n*1000 >= N:
        print(n*1000 - N)
        break
    n += 1

Solution (Python):
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
print((100000000-n)%1000)

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

Solution (Python):
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


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

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

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

Solution (Python):
s = list(map(int, input().split()))
a=int(s[0]/1000) if s[0]%1000==0 else int(s[0]/1000)+1
print(1000*a-s[0])

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from functools import reduce
from math import gcd


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


N = a_int()
for en in range(1000, 10001, 1000):
    if en >= N:
        exit(en - N)

Solution (Python):
out = 0
r = 0
num = int(input())

if(num%1000 == 0): out=0
else:
	r = num%1000
	out = abs(1000-r)

print(out)

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

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

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

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

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

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

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

Solution (Python):
import math
a = input()
b = int(a)
c = 1000
if len(a) < 4:
  print(c-b)
else:
  if a[-4] != '0':
    b = int(a[-3:])
    if b == 0:
      print(int(0))
    else:
      print(c-b)
  elif a[-3] != '0':
    b = int(a[-2:])
    print(c-b)
  elif a[-2] != '0':
    b = int(a[-1:])
    print(c-b)
  else:
    print(int(0))

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

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

s, f = math.modf(i/1000)
if s != 0.0:
    f += 1
v = int((f) * 1000) - i
if v >= 1000:
    print(2000 - v)
else:
    print(v)

Solution (Python):
n = int(input())
o = n + 1000 
o = o // 1000 
o = o * 1000 

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

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

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

Solution (Python):
from math import ceil

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

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

Solution (Python):

"""
Created on Sun Jul  5 20:25:04 2020

@author: KevinLU
"""
money = int(input())

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

Solution (Python):
import math
def solve(n):
    rou = math.ceil(n / 1000);
    rou = rou * 1000
    if(rou == n):
        return 0
    else:
        return rou - n;

print(solve(int(input())))

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

while N > 1000:
    N = N - 1000

M = 1000 - N
print(M)

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

while N > 0:
  if N >= 1000:
    N = N-1000
  else:
    N= 1000-N
    break

print(N)

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

Solution (Python):
t=int(input())
m=0
while 1000*m<t:
    m=m+1
c=1000*m-t
print(c)

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

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

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

M = str(N)

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

elif N <= 9999 and N > 1000:
    print(1000 - int(M[1:4]))

else:
    print(1000 - N)

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

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

Solution (Python):
n = int(input())
left = 0
change = 0
if n >= 1 and n <= 10000:
    left = n % 1000
    change = 1000 - left
    if change == 1000:
        print(0)
    else:
        print(change)
else:
    print()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


mod = 10 ** 9 + 7

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