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())
import math
x = math.ceil(n / 1000) * 1000
print(x - n)

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

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

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

print(1000 - (N % 1000))

Solution (Python):
import sys
import math
def II():
	return int(sys.stdin.readline())

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

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

def SI():
	return sys.stdin.readline().strip()
n = II()
print((1000-(n%1000))%1000)

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

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

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

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

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

Solution (Python):

import sys


def solve(a: int):
    print(0 if a % 1000 == 0 else 1000-a%1000)
    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):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import ceil
N = int(input())
print(ceil(N/1000)*1000-N)

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

Solution (Python):
import math

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

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

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

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

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

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

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

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

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

Solution (Python):
def LI():return list(map(int,input().split()))
def I(): return int(input())

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

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

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

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

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

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

print(cnt * 1000 - N)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


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


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  


N = ni()

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

        
resolve()

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

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

print((1000-x)%1000)

Solution (Python):
import sys


N = int(input())




A = N%1000
if A ==0:
    print(0)
    sys.exit()
ans = 1000-A











print(ans)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	N = inputInt()

	for i in range(100000):
		tmp = i * 1000
		
		ans = tmp-N
		if ans >= 0:
			print(ans)
			sys.exit()

	print(N)



if __name__ == "__main__":
	main()

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

Solution (Python):



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


print(main())

Solution (Python):

import sys


def solve(N: int):
    if N % 1000 != 0:
        print(1000 - N % 1000)
    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):
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(readline())

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


if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input())
def ceil(a,b):
	return -(-a//b)
print(ceil(n, 1000)*1000-n)

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

Solution (Python):
import sys

import math
import itertools
import random
d = int(input())

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

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

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

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

Solution (Python):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


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


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


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


def F(): return float(input())


def ST(): return input().replace('\n', '')


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


if __name__ == '__main__':
    main()

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

for i in range(1,100):
    if n <= i*1000:
        k = i*1000
        break

print(k-n)

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

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

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

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

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7






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

Solution (Python):




import sys
input = sys.stdin.readline



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

    res = N % 1000
    res = 1000 - res
    res %= 1000

    print(res)



main()

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

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

    print((10000 - N) % 1000)

if __name__ == '__main__':
    main()

Solution (Python):

N=int(input())

while(1):
    N=N-1000
    if(N<=0):
        print(-N)
        break

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

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


main()

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

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

ans = N%1000

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

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

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

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

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
import math
setrecursionlimit(10 ** 7)

n = int(input())

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
for i in range(1,11):
    if i*1000 >= N:
        print(i*1000-N)
        break

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

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

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

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

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

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

Solution (Python):
import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

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

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

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

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

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

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

print(ans)

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

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

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

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

s = 10000 - N
print(s%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):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

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



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

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

a = 0
while a < n:
    a += 1000
print(a-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
if a!=0:
    a=1000-a
print(a)

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

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

total = 0
for i in range(100000):
    if total >= n:
        print(total - n)
        break
    total += 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(((N//1000)+1)*1000-N)

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

    print((10000 - x) % 1000)

if __name__ == '__main__':
    main()

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

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

Solution (Python):

import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

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

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

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

money=N%1000

ans=1000-money

if ans==1000:
    ans=0

print(ans)

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

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

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

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

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

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

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




if __name__ == '__main__':
    main()


"""
	n, m = LI()
	dist = np.full((n,n), INF)
	bridges = []
	for i in range(n):
		dist[i, i] = 0
	for i in range(m):
		a, b, c = LI()
		dist[a-1][b-1] = c
		dist[b-1][a-1] = c
		bridges.append((a,b,c))
	for i in range(n):
		for j in range(n):
			for k in range(n):
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
	for a, b, c in 

"""

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

Solution (Python):
import sys
import math

N=int(sys.stdin.readline())

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    ans = 10000 - N
    ans = ans%1000
    print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop



n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()

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

print(ans)

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

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

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

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

Solution (Python):

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

if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):

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

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

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




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

print(-N)

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

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

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

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

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    if N % 1000 == 0:
        print(0)
    else:
        print(1000-N%1000)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

sen = N // 1000
amari = N % 1000

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

Solution (Python):
_MULTITEST = False

def solve():
    n = int(input())
    k = (n // 1000) + (1 if n % 1000 != 0 else 0)
    print(k*1000 - n)


if __name__ == "__main__":
    t = (int(input()) if _MULTITEST else 1)
    for tt in range(t):
        solve()

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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

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

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

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

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

print((10000-n)%1000)

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

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

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

Solution (Python):

import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline




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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N):
    while N > 0:
        N -= 1000
    return -N


if __name__ == "__main__":
    N = int(input())
    print(solve(N))

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

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

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

Solution (Python):


import copy
import random
import bisect 
import fractions 
import math
import sys
import collections
from decimal import Decimal 

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

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

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

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

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

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

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

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
for i in range(1000, 11000, 1000):
    if i >= N:
        print(i-N)
        break

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

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

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

print(a)

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

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

Solution (Python):
n = int(input())
m = n
while m % 1000 != 0:
    m += 1
print(m-n)

Solution (Python):
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



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

main()

Solution (Python):
import sys
import math

def read_int():
    line = sys.stdin.readline().rstrip('\n')
    return int(line)

def read_int_list():
    line = sys.stdin.readline().rstrip('\n')
    return [int(e) for e in line.split(' ')]

N = read_int()

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

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

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

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

Solution (Python):

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

Solution (Python):

import math 
N = int(input())

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

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

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




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

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 sys

from sys import stdin
input = lambda: stdin.readline().rstrip()


N = int(input())

m = N % 1000

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

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

Solution (Python):






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

main()

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

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


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

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

Solution (Python):




n = int(input())


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


print(ans)

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

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






change = N%1000

if change == 0:
    print(0)
    exit()

print(1000-change)

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

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

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

Solution (Python):


N, = map(int, input().split())

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