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())
for i in range(100):
    if i*1000>=N:
        print(i*1000-N)
        break

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

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

Solution (Python):

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

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

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

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

Solution (Python):
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    print(((N+1000-1)//1000)*1000-N)


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
import math  
from collections import deque  
from typing import Deque, Dict, List, Optional, Tuple, Union  


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


if __name__ == "__main__":
    N = int(input())
    main(N)

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

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

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  for i in range(20):
    x=i*1000
    if x>=n:
      return x-n


print(main())

Solution (Python):
def examA():
    N = I()
    ans = (10000 - N)%1000
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(input())
print((1000-N%1000)%1000)

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

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

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

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

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

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


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
import math

n = int(input())

print(math.ceil(n / 1000) * 1000 - 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())
res = 1000- N % 1000
print(res if res != 1000 else 0)

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

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

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    return (1000 - N % 1000) %1000


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

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

if __name__ == "__main__":
    main()

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

print((1000 - n) % 1000)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import math
import fractions
import collections
import itertools
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)

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

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

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

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

print((-N)%1000)

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

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

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    
    n = (N + 999) // 1000
    ans = n * 1000 - N
    print(ans)
    
    return


if __name__ == '__main__':
    main()

Solution (Python):

N, = [int(x) for x in input().split()]

print(-N % 1000)

Solution (Python):
def main():

    N = int(input())
    if N % 1000 == 0:
        return 0
    else:
        return 1000 - N % 1000

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
import math
print(math.ceil(n/1000)*1000 - n)

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

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

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

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

    return None

if __name__ == '__main__':
    main()

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
print(-(-N//1000)*1000-N)

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
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 [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():

    N = INT()
    print((1000 - N % 1000) % 1000)
    return


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    n = int(input())
    print(ceil(n / 1000) * 1000 - n)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)
mod = 1000000007

def solve():
    n =I()
    print(-n%1000)
    return


if __name__ == "__main__":
    solve()