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: Runtime Error

Solution code:
N=int(input())
sen = N / 1000:
print(sen)
 
for N in 10000:
  if N % 1000 == 0：
  print(0)
else:
  atai = N - sen
  print(sen + atai )

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = input()
R = N % 1000

if R = 0:
    print(0)

else:
    print(abs(R-1000))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

n = 1000 - N
if 1000 < N:
  m = n * (-1)
else:
  pass

print(int(str(m)[-3])*100)

Submission status: Runtime Error

Solution code:
N=int(input())
sen = N / 1000:
 
for N in 10000:
  if N % 1000 == 0：
  print(0)
else:
  atai = N - sen
  print(sen + atai )

Submission status: Runtime Error

Solution code:
N = input()

ans = int(N[1:4])

ans = 1000 - ans

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

Submission status: Runtime Error

Solution code:
N = int input()
sen = N / 1000:
 
for N in 10000:
  if N % 1000 == 0：
  print(0)
else:
  atai = N - sen
  print(sen + atai )

Submission status: Runtime Error

Solution code:
n = int(input())

if n % 1000 == 0:
    print("0")
else:
    s = str(n)
    N = 10 - int(s[-3])
    print(N*100)

Submission status: Runtime Error

Solution code:
N = input()
R = N%1000

if R == 0:
    print(0)

else :
    print(abs(R-1000))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=str(input())
print(1000-int(n[1:4]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = 10000 - N
a = str(A)
print(a[-3]+a[-2]+a[-1])

Submission status: Runtime Error

Solution code:
N = int(input())
if int(str(N)[1:]) ==0:
  print(0)
else:
    print(1000-int(str(N)[1:]))

Submission status: Runtime Error

Solution code:
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
       x = s*1000 - n 
       break()
print(x)

Submission status: Runtime Error

Solution code:
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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


# for i in range(1, 10+1):
#     have = 1000 * i

#     if 0 <= have - N < 1000:
#         print(have - N)
#         exit()

Submission status: Runtime Error

Solution code:
N = input()
x = N[-3]+N[-2]+N[-1]
print (1000 - int(x))

Submission status: Runtime Error

Solution code:
use strict;
use warnings;

my $a = <STDIN>;
chomp($a);
$a = int($a);

my $result;
my $tmp;

if ($a <= 1000){
    $result = 1000 - $a;
}else{
    $tmp = $a % 1000;
    $result = $tmp;
    if ($tmp > 0){
        $tmp = 1000 - $tmp;
        $result = $tmp;
    }
}
print("$result\n");

Submission status: Runtime Error

Solution code:
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
       x = s*1000 - n 
       
print(x)

Submission status: Runtime Error

Solution code:
n=input()
print(1000-(int(n[1:4])))

Submission status: Runtime Error

Solution code:
N = int(input())

for i in 11:
    x = 1000 * i - N
    if x < 0:
        continue
    else:
        exit()
ans = x % 1000
print(ans)

Submission status: Runtime Error

Solution code:
cost = input()[0]
dvi, mod = dvimod(int(cost), 1000)
bills = dvi + 1
change = bills - mod
print(change)

Submission status: Runtime Error

Solution code:
N=int(input())
quotient=N//1000
for i in range(quotient+1):
  change=N-1000
  if change=<0:
    change=abs(change)
    print(change)
  else:
    continue

Submission status: Runtime Error

Solution code:
N = str(input())

if len(N) <4:
    print(1000-N)
elif len(N) == 5:
    print(10000-N)
else:
    n = (1+int(N[0]))*1000 
    print(n - int(N))

Submission status: Runtime Error

Solution code:
N = int input()
sen = N / 1000:

for 1000 in 10000:
  if N % 1000 == 0：
  print(0)
else:
  print(sen + 1000-N)

Submission status: Runtime Error

Solution code:
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
       x = s*1000 - n 
       break
print(x)

Submission status: Runtime Error

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
# sys.setrecursionlimit(1000000)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
# A = [LI() for _ in range(N)]

l = len(str(N))

if l <= 3:
    a = 1000 - N
elif N % 1000 == 0:
    a = 0
else:
    a = 1000 - (N % 1000) 

print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main(money):
  a  = money % 1000
  if a != 0:
    change = 1000 - a
    return change
  elif a = 0:
    change = 0
    return change

Submission status: Runtime Error

Solution code:
N = int(input())
c = [0] * 4
for i in range(N):
    X = input()
    if X == "AC":
        c[0] += 1
    elif X == "WA":
        c[1] += 1
    elif X == "TLE":
        c[2] += 1
    else:
        c[3] += 1
print("""AC x {}
WA x {}
TLE x {}
RE x {}""".format(c[0],c[1],c[2],c[3]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
n = str(n)
p = n[-3]+n[-2]+n[-1]
print(int(p))

Submission status: Runtime Error

Solution code:
N = int(input())

ans = []

for i in range(1,10):
  if (1000 * i) - N  >= 0:
    ans.append((1000 * i) - N )
    
print(min(ans))

Submission status: Runtime Error

Solution code:
N = int(input())

for i in 11:
    ans = (1000*i - N) % 1000

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
result = [0,0,0,0]
for n in range(N):
    S = input()
    if S == "AC":
        result[0] += 1
    elif S == "WA":
        result[1] += 1
    elif S == "TLE":
        result[2] += 1
    else:
        result[3] += 1
name = ["AC","WA","TLE","RE"]
for res,nam in zip(result,name):
    print("%s x %d"%(nam,res))

Submission status: Runtime Error

Solution code:
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
        x = s*1000 - n 
        break
print(x)

Submission status: Runtime Error

Solution code:
a = input()

st = str(a)


if st[1:4] == "000":
  print(0)

else:
  z = st[1:4]
  print(1000 - int(z))

Submission status: Runtime Error

Solution code:
H, W, K = [int(s) for s in input().split()]

cs = []

for _ in range(H):
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1

print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")

Submission status: Runtime Error

Solution code:
#N=price
low_price = N % 1000
low_price = input(N % 1000)
print(low_price)

Submission status: Runtime Error

Solution code:
a = input()

st = str(a)


if a[1:4] == "000":
  print(0)

else:
  z = a[1:4]
  print(1000 - int(z))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = input()
p = n[-3]+n[-2]+n[-1]
print(int(p))

Submission status: Runtime Error

Solution code:
N = int(input())

for i in 11:
    x = 1000*i - N
ans = x % 1000
print(ans)

Submission status: Runtime Error

Solution code:
def change(money):
  a  = money % 1000
  if a != 0:
    change = 1000 - a
    return change
  elif a = 0:
    change = 0
    return change
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())


n = str(N)
a = n[-1]
b = n[-2]
c = n[-3]

A = int(a)+10*int(b)+100*int(c)

if 1000-A!=1000:
    print(1000-A)

else:
    print(0)

Submission status: Runtime Error

Solution code:
n = int(input())

if n >= 1000:
    n = int(str(n[1:]))

if n > 0:
    ans = 1000 - n
else:
    ans = 0

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
d = {}
d['AC'] = 0
d['WA'] = 0
d['TLE'] = 0
d['RE'] = 0

for i in range(N):
  x = input()
  d[x] +=1
for j in d.keys():
  print(j + " " + "x" + " " + str(d[j]))
  print("\n")

Submission status: Runtime Error

Solution code:
N = int(input())

for i in 11:
    x = 1000*i - N
    ans = x % 1000
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n,0,-1000):
    count += 1
print(1000-i

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,x;
  cin>>N;
  x=N/1000+1;
  if(N%1000==0){
    cout<<0<<endl;
  }
  else{
    cout<<1000*x-N<<endl;
  }
}

Submission status: Runtime Error

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

a = int(N[-3])
b = int(N[-2])
c = int(N[-1])
x = 100*a + 10*b + c
ans = 1000 - x
if ans == 1000:
    ans = 0
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
def main():
    with open('in.csv', 'r') as r:
        args = list(r.readlines())
    N = int(args[0])
    use = math.ceil(N/1000)
    print(1000*use - N)
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input_yen = int(input())
unit_yen = 1000

required_bill = int(float(input_yen)/unit_yen) * unit_yen
return required_bill - input_yen

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def change(money):
  a  = money % 1000
  if a != 0:
    change = 1000 - a
    return change
  elif a = 0:
    change = 0
    return change

Submission status: Runtime Error

Solution code:
a = str(input())

  
if len(a) == 5 or a[1:4] == "000":
  print(0)
  
elif len(a) == 3:
  print(1000 - int(a))
  
else:
  z = a[1:4]
  if z == "000":
    print(0)
  else:
    print(1000 - int(z))

Submission status: Runtime Error

Solution code:
n=int(input())
k=1000
for i in range(1,10001):
  if n>k:
    k=k*i
  else:
    prinr(k-n)
    break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=1
turi=1000*n

while N<1000*n:
  if N<1000*n:
    return turi=1000*n-N
  else:
    n+=1

Submission status: Runtime Error

Solution code:
a = str(input())

  
if len(a) == 5:
  print(0)
  
elif len(a) == 3:
  print(1000 - int(a))
  
else:
  z = a[1:4]
  if z == "000":
    print(0)
  else:
    print(1000 - int(z))

Submission status: Runtime Error

Solution code:
N=input()
A=N%1000
print(A)

Submission status: Runtime Error

Solution code:
N = input()
N_1 = N[-3] + N[-2] + N[-1]

if N_1 == "000":
    print(0)
else:
    print(1000-int(N_1))

Submission status: Runtime Error

Solution code:
N=int(input())
A=0
for i in range(0,10):
    i=i+1
    A=i+"000"
    if N<=A:
        print(A-N)
        break

Submission status: Runtime Error

Solution code:
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n
 
print(val)

Submission status: Runtime Error

Solution code:
n = int(input())
m = str(n)
if m[-1] == m[-2] == m[-3] == "0":
    print(0)
else:
    print(1000 - int(m[-3]+m[-2]+m[-1]))

Submission status: Runtime Error

Solution code:
n = input()
n_l = int(n[1:])
if n_l==0:
    print(0)
else:
    print(1000-n_l)

Submission status: Runtime Error

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

    print(abs(n))
resolvea()

Submission status: Runtime Error

Solution code:
n = input()

ans = 1000-int(n[1:])
if(ans%1000==0):
    print(0)
else:print(ans)

Submission status: Runtime Error

Solution code:
n = input()

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

print(ans)

Submission status: Runtime Error

Solution code:
n = input()
m = str(n)
if m[-1] == m[-2] == m[-3] == "0":
    print(0)
else:
    print(1000 - int(m[-3]+m[-2]+m[-1]))

Submission status: Runtime Error

Solution code:
N = input()

print(1000-N%1000)

Submission status: Runtime Error

Solution code:
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n

print val

Submission status: Runtime Error

Solution code:
N = input()
while N<1000:
    N = N - 1000
print(sum)

Submission status: Runtime Error

Solution code:
n=eval(input())
t=(n//1000)+1
f=1000*t-n
pring(f)

Submission status: Runtime Error

Solution code:
N=int(input())
A=""
for i in range(0,10):
    i=i+1
    A=int(i+"000")
    if N<=A:
        print(A-N)
        break

Submission status: Runtime Error

Solution code:
n = input()
value = n[-3]+n[-2]+n[-1]
#print(value)
value_int = int(value)
if value == '000':
    print(0)
else:
    print(1000 - value_int)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
n1 = int(n[1:])
print(1000-n1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
res = N%1000
if res ==0:
  return res
else:
  return 1000-res

Submission status: Runtime Error

Solution code:
def main():
    with open('in.csv', 'r') as r:
        args = list(r.readlines())
    N = int(args[0])
    print(N%1000)
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    N = str(input())
    N = N[-3]
    N = int(N)
    N = 10 - N
    if N == 10:
        print(0)
    else:
        print(N*100)
main()

Submission status: Runtime Error

Solution code:
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000

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

Submission status: Runtime Error

Solution code:
n = int(input())

ans = []
for i in range(1, 10):
    if 1000 * i - n >= 0:
        ans.append(1000*i - n)

print(min(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
L = str(N)
L1 = str(L[-3] + L[-2] + L[-1])
N1 = int(L1)
if N1 == 0:
    print(0)
else:
    print(1000 - N1)

Submission status: Runtime Error

Solution code:
s = str(input())
n = [s[-3], s[-2], s[-1]]
n = ''.join(n)
n = int(n)
if n == 0:
    print(0)
else:
    print(1000 - n)

Submission status: Runtime Error

Solution code:
N = input()

print(N%1000)

Submission status: Runtime Error

Solution code:
cost = input()[0]
mod = cost % 1000
print(mod)

Submission status: Runtime Error

Solution code:
n = list(input())
if int("".join(n)) % 1000 == 0:
    print("0")
else:
    print((10 - int(n[-3])) * 100)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = input()
M = N[1:]
O = int(M)
if O == 0:
    print(0)
else:
    print(1000-O)

Submission status: Runtime Error

Solution code:
a = input()

mod = a % 1000

b = mod - 1000

c = abs(b)

print(c)

Submission status: Runtime Error

Solution code:
#ABC173 A
n = input()
s = int(n[-3])*100
if s == 0:
  print(0)
else:
  print(1000-s)

Submission status: Runtime Error

Solution code:
N = input()

s = int(N[len(N)-3])*100+int(N[len(N)-2])*10+int(N[len(N)-1])
if(s==0):
  print(0)
else: 
  print(1000-s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
tmp = int(n[-3])
if tmp==0:
    print(0)
else:
    print((10-tmp)*100)

Submission status: Runtime Error

Solution code:
n = str(input())
if int(n)==10000:
    print(0)
else:
    print(1000-int(n[1:4]))

Submission status: Runtime Error

Solution code:
#a
n = int(input())
ans = n//1000
print(n%(ans*1000))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
mai = n//1000
mai += 1
if mai*1000-n == 1000:
    print((mai-1)*1000-n)
else:
    print(mai*1000-n)

Submission status: Runtime Error

Solution code:
n = list(input())
if n % 1000 == 0:
    print("0")
else:
    print((10 - int(n[-3])) * 100)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():

    n = int(input())
    a = n//1000
    print(n%(a*1000))
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = input()
n = int(n[1:])

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

Submission status: Runtime Error

Solution code:
n = input()

m = int(n[1:])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<algorithm>
using namespace std;



int main(){
    int N;
    cin >> N;
    int moD = N%1000;
    if (moD == 0) moD = 1000;
    cout << 1000-moD<<endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
v

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:

# Author : raj1307 - Raj Singh
# Date   : 05.07.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def ii():  return int(input())
def si():  return input()
def mi():  return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li():  return list(mi())

def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def isPrime(n) : # Check Prime Number or not 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True



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




def main():
    


    #for _ in range(ii()):



    n=ii()

    r=n%1000
    r=(1000-r)%r


    print(r)


















    








# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

Submission status: Runtime Error

Solution code:
N = input()
otsuri = N % 1000
if otsuri > 0
    orsuri = 1000 - otsuri
print(otsuri)

Submission status: Runtime Error

Solution code:
#a
n = int(input())
print(n%((n//1000)*1000))

Submission status: Runtime Error

Solution code:
a = input().rstrip()
ans = a % 1000
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>

using namespace std;

int main()
{
   int n;
   cin >> n;
   if(n%1000==0) cout << 0;
   else cout << 1000-(n%1000);
   
   return 0;
}

Submission status: Runtime Error

Solution code:
n = list(input())
print(int(n[-3] + n[-2] + n[-1]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import sys

def main():

    n = int(input())
    a = n//1000
    print(n%(a*1000))
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = input()
n = int(n[1:])
if 1000 - n == 1000:
    print(0)
else:
    print(1000 - n)

Submission status: Runtime Error

Solution code:
n = str(input())
print(int(n[1:4]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

# Author : raj1307 - Raj Singh
# Date   : 05.07.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def ii():  return int(input())
def si():  return input()
def mi():  return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li():  return list(mi())

def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def isPrime(n) : # Check Prime Number or not 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True



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




def main():
    


    #for _ in range(ii()):



    n=ii()

    r=n%1000
    r=(1000-r)%r


    r=print(r)


















    








# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()