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.



Sample input:
1900


Sample output:
100

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
print (1000 - n%1000) % 1000

Submission status: Accepted

Solution code:
# input
N = int(input())

# process
ans = N
while ans > 0:
    ans -= 1000

ans = -ans

# output
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

a=n%1000

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

    print(1000-a)

Submission status: Accepted

Solution code:
a = int(input(""))
if 1000 >= a:
    print(1000 - a)
elif 2000 >= a > 1000:
    print(2000 - a)
elif 3000 >= a > 2000:
    print(3000 - a)
elif 4000 >= a > 3000:
    print(4000 - a)
elif 5000 >= a > 4000:
    print(5000 - a)
elif 6000 >= a > 5000:
    print(6000 - a)
elif 7000 >= a > 6000:
    print(7000 - a)
elif 8000 >= a > 7000:
    print(8000 - a)
elif 9000 >= a > 8000:
    print(9000 - a)
else:
    print(10000 - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N):
    money = 1000*(i+1)
    if(money >= N):
        change = money - N
        break

print(change)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
mod = n%1000

print(1000 - mod if mod else 0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from 20200802 1816
N = int(input())

rest = N%1000
if rest == 0:
    print(f"{0}")
else:
    print(f"{1000-rest}")

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())

k = n
a = 0

while(n > 0):
  
  n = n - 1000
  a = a + 1000
  
print(a - k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n=int(next(sys.stdin))
print((n+999)//1000*1000-n)

Submission status: Accepted

Solution code:
import sys
n=int(next(sys.stdin))
r=n%1000
print(1000-r if r>0 else 0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = 0
while x < N :
  x = x + 1000
print(x-N)

Submission status: Accepted

Solution code:
N = int(input())
n = N % 1000

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
while n > 0:
    n -= 1000


print(-n)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
remainder = N % 1000

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
1<=N<=10000
if((N%1000)==0):
	print("0")
else:
	print(1000-(N%1000))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
y = int(int(input())%1000)
if y == 0:
  print(0)
else:
  print(1000-y)

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = n % 1000
a = 1000 - a
a = a % 1000

print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
num=0
while n>num:
  num+=1000
print(num-n)

Submission status: Accepted

Solution code:
N = int(input())
mod = N%1000
yen = (1000 - mod)%1000
print(yen)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
money = int(input())

print((1000 - money % 1000) % 1000)

Submission status: Accepted

Solution code:
money = int(input())

for i in range(1, 11):
    if money <= i * 1000 :
        print(i * 1000 - money)
        exit()
    else:
        pass

Submission status: Accepted

Solution code:
N = int(input())
while N > 0:
	N -= 1000
if N == 0:
  print(N)
elif N < 0:
  print(-N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input().rstrip())
n = [i for i in range(1,11) if(a <=i *1000)]
print((min(n)*1000) - a)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

a = N % 1000

ans = 0
if a > 0 :
 ans = 1000 - a 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
while n > 0:
    n -= 1000

if n < 0:
    print(-n)
elif n == 0:
    print(n)

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
N=int(input())
a=int(N/1000)
otsuri=(a+1)*1000-N
if otsuri==1000:
    otsuri=0
print(otsuri)

Submission status: Accepted

Solution code:
a = int(input())
n= 1000
f=1000
while(n<a):
    n= n+f  
s= abs(n-a)
print(s)

Submission status: Accepted

Solution code:
price = int(input())
print((1000 - price % 1000) % 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
fee = int(input())

fee = fee % 1000
pay = 1000
if fee == 0: pay = 0
print(pay - fee)

Submission status: Accepted

Solution code:
import sys
import numpy as np
from math import ceil

def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(Ss())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N = int(input())

q = N / 10**3
pay = math.ceil(q) * 10**3

print(pay - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def solve(string):
    return str((1000 - (int(string) % 1000)) % 1000)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
N = int(input())
pay = N // 1000
if N % 1000 != 0:
    pay += 1
ans = pay * 1000 - N
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
print(999-(n-1)%1000)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=str(N)
s = ""
if N <1000:
    ans = 1000 - N
    print(ans)
    exit()
for i in range(3):
    s = S[len(S)-1-i] + s

n = int(s)
ans = 1000 - n
if ans == 1000:
    ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
i = N // 1000
j = i*1000
if i == 0 or j != N:
    i = i + 1
    j = i * 1000
print(j - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(1, 11):
	if 1000*i >= N:
		ans = 1000*i - N
		break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
if N<=1000:
    print(1000-N)
if 2000>=N>1000:
    print(2000-N)
if 3000>=N>2000:
    print(3000-N)
if 4000>=N>3000:
    print(4000-N)
if 5000>=N>4000:
    print(5000-N)
if 6000>=N>5000:
    print(6000-N)
if 7000>=N>6000:
    print(7000-N)
if 8000>=N>7000:
    print(8000-N)
if 9000>=N>8000:
    print(9000-N)
if 10000>=N>=9000:
    print(10000-N)

Submission status: Accepted

Solution code:
n = int(input())
div = n%1000 
if div == 0:
  print("0")
else:
  num = n//1000 
  num = num + 1
  otu = num*1000 - n 
  print(otu)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n=int(input())
total = math.ceil(n/1000)

print((total)*1000-n)

Submission status: Accepted

Solution code:
n = input()
n = n[-3:]
if n == '000':
  print('0')
else:
  print(str(1000 - int(n)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
n2 = str(n)[-3:]
if int(n2) == 0:
    print(0)
else:
    ans = 1000 - int(n2)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

while x > 0:
  x -= 1000
  
print(x*-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N % 1000 == 0:
    ans = 0
else:
    i = int(N/1000)
    ans = (i+1)*1000 - N

print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.buffer.readline
import os
from math import*

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

Submission status: Accepted

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

print(redual)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
#ABC173
N = int(input())
if N % 1000 == 0:
    print(0)
else:
    print((1000-(N % 1000)))

Submission status: Accepted

Solution code:
n = int(input())
res = n % 1000
if (res > 0):
  res = 1000 - res
print(res)

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = (10000-n)%1000
print(x)

Submission status: Accepted

Solution code:
n = int(input())
x = (10000-n)%1000
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
otsuri=10000
for i in range(11) :
    if 1000*i-N>=0 :
        coin=1000*i-N
        otsuri=min(otsuri,coin)
print(otsuri)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
remainder= 1000 - N%1000
if remainder==1000:
    remainder=0
print(remainder)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
main=int(input().rstrip())
x=main%1000
if x==0:
    print(x)
else:
    print(1000-x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import datetime
import string
import re
import math

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

print(1000 - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
mod = N % 1000
if mod == 0:
    print(0)
    exit()
print(1000-mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
add = 1000 - N%1000

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

if n % 1000 == 0:
    ans = 0

else:
    ans = 1000 - n % 1000

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
cnt=0
while cnt<N:
    cnt+=1000
print(cnt-N)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def solve(n, debug=0):
    m = 1000
    r = n % m
    return 0 if r == 0 else m - r


def main(istr, ostr):
    n = int(istr.readline())
    print(solve(n), file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
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()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
amari = int(a)%1000
otsuri = 1000 - amari
if otsuri == 1000:
  otsuri = 0

print(otsuri)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 12):
  if (i*1000 < N):
    continue
  else:
    print(i*1000 - N)
    break

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
def main():
	N = int(input())
	while N > 0:
		N = N - 1000
	print(-N)


if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
surplus = int(input()) % 1000
change = 1000 - surplus if surplus else 0
print(change)

Submission status: Accepted

Solution code:
import math
n=int(input())
x=10000000
for i in range(1000):
  if i*1000>=n:
  	x=min(i*1000-n,x)
  
print(x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

temp = N - (N // 1000) * 1000
if temp:
    print(1000 - temp)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.8.2)

import math
import statistics
import numpy as np
import queue
import itertools
import functools 

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

Submission status: Accepted

Solution code:
S = int(input())
while True:
    if S <= 1000:
        break
    S -= 1000

print(1000-S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

x = (1000 - N%1000)%1000

print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b) 

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
payment = int(input().rstrip())
if (payment/1000) > math.floor(payment/1000):
    p_1 = math.floor(payment/1000)+1
else:
    p_1 = payment/1000

change = int(p_1*1000 - payment)
print(change)

Submission status: Accepted

Solution code:
# Payment


def main(n):
    m = n % 1000
    if m != 0:
        return 1000 - m
    else:
        return m


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
Y = 10000

change = (Y - n) %1000
print(change)

Submission status: Accepted

Solution code:
N = int(input())

print((10000-N)%1000)

Submission status: Accepted

Solution code:
taka = int(input())
remainder = taka % 1000
ans = 1000 - remainder
print(ans % 1000)

Submission status: Accepted

Solution code:
N_value = int(input())

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

Submission status: Accepted

Solution code:
str = input()
int = int(str[-3:])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
A=1000*(N//1000)-N
B=((N//1000)+1)*1000-N
if A<=B and A>=0:
  print(int(A))
else:
  print(int(B))

Submission status: Accepted

Solution code:
n = int(input())
c = n % 1000
if c == 0:
    print("0")
else:
    print(1000 - c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
import math

price = int(input())
payment = math.ceil(float(price) / 1000) * 1000
result = payment - price
print(int(result))

Submission status: Accepted

Solution code:
payment = int(input())
if payment%1000 == 0:
	print(0)
else:
	print(1000-payment%1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
payment = int(input())

bucks = 1000

if payment%bucks == 0:
  change = 0
else:
  receive = payment//bucks + 1
  change = receive*bucks - payment

print(change)

Submission status: Accepted

Solution code:
import math

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

main()

Submission status: Accepted

Solution code:
N = int(input())

answer = 1000 - (N%1000)
answer = answer%1000

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N=int(input())
ans=(1000-(N%1000))%1000
print(ans)

Submission status: Accepted

Solution code:
import sys 
input = sys.stdin.readline

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m = int(input())
r = m % 1000
a = r if r == 0 else 1000 - r
print(a)

Submission status: Accepted

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