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

Solution (Python):
a=input()
a=int(a)
c=0
b=0
d=0
while c<a:
  c=c+1000

d=c-a
print(d)

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

Solution (Python):

N = int(input())
maisuu = 0
while N - 1000 * maisuu >= 1000:
    maisuu += 1
if(N - 1000 * maisuu == 0):
    print(1000 * (maisuu) - N)
else:
    print(1000 * (maisuu+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:
  res = 0
else :
  res = 1000 - (N % 1000)
print(res)

Solution (Python):


import sys

def main():
    n = int(input())
    if n==0:
        print(0)
        exit()
    for i in range(11):
        if i*1000 >= n:
            print(i*1000-n)
            break

if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

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

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

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

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

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

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


r = N % 1000

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

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

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

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

if N <= 1000:
  print(1000 - N)
elif N <= 2000:
  print(2000 - N)
elif N <= 3000:
  print(3000 - N)
elif N <= 4000:
  print(4000 - N)
elif N <= 5000:
  print(5000 - N)
elif N <= 6000:
  print(6000 - N)
elif N <= 7000:
  print(7000 - N)
elif N <= 8000:
  print(8000 - N)
elif N <= 9000:
  print(9000 - N)
else:
  print(10000 - N)

Solution (Python):

N = int(input())

yen = (N // 1000)  
if N % 1000 != 0:
  yen += 1

print(yen * 1000 - N)

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

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

Solution (Python):
import math

i = int(input())

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

print(1000 - (i % 1000))

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

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

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

if n%1000:
    bills = n//1000 + 1
else:
    bills = n//1000

ans = bills * 1000 - n
print(ans)

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

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

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

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

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

Solution (Python):

n=int(input())
for i in range(100):
    if n<=1000:
        break
    else:
        n=n-1000
ans=1000-n
print(ans)

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


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

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

print(x-n)

Solution (Python):
import math
def task():
    n=int(input())
    if(n>=1000):
        a=math.ceil(n/1000)
        a=a*1000
        n=a-n
    else:
        n=1000-n
    print(n)
def default():
    t=1
    while(t):
        t-=1
        task()
if(__name__=="__main__"):
    default()

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

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

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

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

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

Solution (Python):






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

Solution (Python):
N = int(input())
answer = 0
for i in range(1, 1000):
  pay = 1000 * i
  if pay >= N:
    answer = pay - N
    break
print(answer)

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

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

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

Solution (Python):
def actual(N):
    if N % 1000 == 0:
        return 0

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

N = int(input())
print(actual(N))

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

Solution (Python):

N = input()
if (int(N) <= 1000):
    print(1000 - int(N))
elif (int(N) % 1000 == 0):
    print(0)
else:
    print(1000 - int(N[1:]))

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n=INT()
    n=n%1000
    if n==0:
        n=1000
    print(1000-n)
if __name__ == '__main__':
    do()

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

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

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

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

Solution (Python):
def Payment():

    money = int(input())

    for n in range(0, 11):
        output = n*1000 - money
        
        if 0 <= output and output < 1000:
            break
    
    print(output)

if __name__ == '__main__':
    Payment()

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

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

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline

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

    return


if __name__ == '__main__':
    main()

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

  print(oturi)

Solution (Python):
import math

N = int(input())

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
m = 0
ans = 0
if(N%1000!=0):
    m = N//1000
    ans = 1000-(N-1000*m)

print(ans)

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

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

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

Solution (Python):
import math

if __name__ == '__main__':
    n = int(input())
    num = abs(n-(math.ceil(n/1000)*1000))
    print(num)

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

Solution (Python):

N = int(input().strip())

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

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

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

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

n = N/1000

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

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

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

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

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

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

i=1

while i*1000 < n:
    i += 1

print(i*1000 -n)

Solution (Python):
n=int(input())
for i in range(1,11):
    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())
k=n//1000
if n%1000!=0:print((k+1)*1000-n)
else:print(0)

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

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

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

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

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

Solution (Python):
import sys
n = int(input())
for i in range(100):
  if 1000*i >= n:
    print(1000*i - n)
    sys.exit()

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

for i in range(1000):
    if n>1000:
        n=n-1000
    else:
        if n==1000:
            ans=0
            break
        else:
            ans=1000-n
            break

print(ans)

Solution (Python):


def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip())
    result = 1000 - n % 1000 if n % 1000 != 0 else 0
    print(result)



if __name__ == "__main__":
    resolve()

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


print(ans)

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

Solution (Python):
n = input()

if int(n[-3:]) == 0:
    ans = 0
else:
    ans = 1000 - int(n[-3:])

print(ans)

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

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

result = 0
for i in range(1, 11):
    value= i*1000
    result = value
    if N-value<=0:
        break
print(abs(N-result))

Solution (Python):

n = int(input())

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

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

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

while money > 1000 :
	if int(money/1000) >= 1:
		money -= 1000

rest = 1000-money
print(rest)

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

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

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

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

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

Solution (Python):



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

        ans=1000-ans
print(ans)

Solution (Python):
import math

n = int(input())

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

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

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())
while ans < n:
    ans += 1000
print(ans-n)

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

print(otsuri)

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

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

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

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

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

Solution (Python):

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






abc173_a()

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

Solution (Python):
N = int(input())
a = N % 1000
if a == 0:
  print(0)
  import sys
  sys.exit()
a = 1000 - a

print(a)

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

Solution (Python):
import math
i = int(input())
ii=1000-(i-math.floor(i/1000)*1000)
if (ii == 1000): ii=0
print (ii)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
pay = 1000
while pay < N:
    pay += 1000

print(pay - N)

Solution (Python):
N = int(input())
print("{}".format(1000 - N % 1000 if N % 1000 != 0 else 0))

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

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

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

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

for i in range(0, 10001, 1000):
    if N <= i:
        break

print( i-N )

Solution (Python):
N = int(input())
s = 0
for i in range(11):
  if s >= N:
    ans = s - N
    break
  else:
    s += 1000
print(ans)

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

remain = product % 1000
if remain != 0:
    change = 1000 - remain
else:
    change = 0
print(change)

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

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

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

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

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

    

if __name__ == '__main__':
    main()

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

for i in range(11):
    if 1000 * i >= n:
        break

print(1000 * i - n)

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

Solution (Python):
import math


def main():
    n = int(input())
    print(1000*math.ceil(n/1000)-n)


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

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

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

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

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

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

A = N % 1000

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

Solution (Python):
N = int(input())
ans = 0
while N > ans:
    ans += 1000

print(ans-N)

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

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

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

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

hoge = N // 1000 + 1

if N % 1000 == 0:
    oturi = 0
else:
    oturi = 1000 * hoge - N

print(oturi)

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

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

Solution (Python):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

Solution (Python):









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

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

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

Solution (Python):



n = int(input())
mai = n//1000
mai += 1
if mai*1000-n == 1000:
    print((mai-1)*1000-n)
else:
    print(mai*1000-n)

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

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

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

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

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

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

Solution (Python):
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N = int(input())
    a = 1000 - N % 1000
    if a == 1000:
        a = 0
    print(a)

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

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

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

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

if (price % 1000) == 0:
	payment = price
else:
	payment = (price // 1000 + 1) * 1000

otsuri = payment - price
print(otsuri)

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

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

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

Solution (Python):
import math

N = int(input())

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

print(res)

Solution (Python):


n = int(input())

i = 1000
while True:
    if n > i:
        i += 1000
    else:
        ans = i-n
        break

print(ans)

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

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

if __name__ == '__main__':
    resolve()

Solution (Python):

import sys
input = sys.stdin.readline
N = int(input())
count =0
ans =-1
while ans <0:
    count +=1
    ans =count *1000 -N
    if ans >=0:
        print(ans)

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 - (-n // 1000) * 1000)

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

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

bills = (n + m - 1) // m

ans = bills*m-n
print(ans)

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

A = N % 1000

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

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

print(i - N)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



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


if __name__ == '__main__':
    main()

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

while 1:
    x = x - 1000
    if x <= 0:
        break

print(abs(x))

Solution (Python):
"""while True:
        break"""
    

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

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

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

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

ans = n % 1000

if ans != 0:
  ans = 1000 - ans

if ans == 0:
  ans == 0
    
print(ans)

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

b = int(a // 1000)

if a % 1000 == 0:
  print(0)
else:
  print(1000*(b + 1) - a)

Solution (Python):
def main():
    n = int(input())
    print(min([i*1000 - n if i*1000 - n >= 0 else float("inf")
               for i in range(1, 100)]))
    return


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

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

cnt = 0

for i in range(1,11):
    if cnt < N:
        cnt += 1000

print(cnt-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):
def main():
    N = int(input())
    a = N % 1000
    while N > 0:
        N -= 1000
    print(-N)

if __name__ == '__main__':
    main()

Solution (Python):

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

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

Solution (Python):

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

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

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

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

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

Solution (Python):
def resolve():
    pay = int(input()[-3:])
    rest = 1000 - pay
    if pay == 0:
        print(0)
    else:
        print(rest)

resolve()

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

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

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

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

Solution (Python):
N=int(input())
minimum=0
for i in range(10):
    if N>minimum:
        minimum+=1000
change=minimum-N
print(change)

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

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

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

temp = a % 1000

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

print(ans)

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

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

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

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

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

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

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

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

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

while True:
    if n > 1000:
        n = n - 1000
    else:
        n = 1000 - n
        break

print(n)

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

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

m = 1000
ans = 0
for i in range(11):
    if m*i >= n:
        ans = i*m
        break
    
print(ans-n)

Solution (Python):
N = input()
n = N[-3:]

ans = 1000 - int(n)

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

Solution (Python):
import numpy as np

N = int(input())

print(int(1000 * np.ceil(N/1000) - N))

Solution (Python):

import sys
input = sys.stdin.readline

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


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

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

Solution (Python):
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools
N=int(input())
count=0
for i in range(N):
    count+=1000
    if count>=N:
        print(count-N)
        sys.exit()

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

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

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

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

while N >= 1000:
  N -=1000
  
if N == 0:
  print(0)
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())
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())

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

Solution (Python):

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

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

print(1000-int(n[-3:]) if 1000-int(n[-3:])!=1000 else 0)

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

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

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

for i in range(1, 11):
  m = 1000 * i
  if m >= n:
    print(m - n)
    break
  else:
    pass

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

Solution (Python):

N=int(input())

calc=N%1000

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

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())
m=n%1000
l=n//1000
print((1000*(1+l)-n if m!=0 else '0'))

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

    a = (n // 1000) * 1000
    a = a if n % 1000 == 0 else a + 1000

    print(a - n)


if 'unittest' not in globals():
    resolve()

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

Solution (Python):
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:
    n = N//1000
    N -= n * 1000
    print(1000-N)