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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
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 

from decimal import *




N = INT()

print((1000 - N%1000)%1000)

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    

    
    
    

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

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

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

Solution (Python):


import sys

class APayment:
    def solve(self, tc=0):
        n = int(input())
        print((1000 - n % 1000) if n % 1000 else 0)


solver = APayment()
input = sys.stdin.readline

solver.solve()

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

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

main()

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

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

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

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

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):




import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy














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)
  exit()
x=n%1000
print(1000-x)

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

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

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

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

Solution (Python):
import sys

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

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

INF = float("inf")


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

Solution (Python):

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations

import bisect


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




N = int(input())

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

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

Solution (Python):

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

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()

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

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

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

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

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

    
main()

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

num = -(-n // 1000)

print(1000 * num - n)

Solution (Python):
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = math.ceil(n/1000)
    ans = 1000*a-n
    print(ans)
    return

if __name__=='__main__':
    Main()

Solution (Python):

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

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

print((1000-(N%1000))%1000)

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

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

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

print(1000 - n)

Solution (Python):
n = int(input())
p = 1000
y = (p - n % p) % p
x = (n + y) // p

print(y)

Solution (Python):
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())






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

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

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

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

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

Solution (Python):


import sys
stdin = sys.stdin

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

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

if __name__ == "__main__":
    main()

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

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

ans = (10000 - N) % 1000

print (ans)

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

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

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
if n%1000==0:
    print(0)
else:
    x=(n//1000+1)*1000
    print(x-n)

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

Solution (Python):










N = int(input())




for i in range(1000):
    if 1000*i - N >= 0:
        print(1000*i - N)
        exit()

Solution (Python):
N = int(input())
pay = 0
while True:
    pay += 1000
    if pay >= N:
        break
print(pay-N)

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


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):















mod = int(1e9+7)

INF = 1<<50

def readInt():
    return list(map(int,input().split()))

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

if __name__=='__main__':
    main()

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

x = 0
while x < n:
   x += 1000
print(x - n)

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

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

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

N = int(input())

print((1000 - N % 1000)%1000)

Solution (Python):

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

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

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

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n = Z()
    x = (n + 1000 - 1)//1000
    print(1000*x - n)

    return

if __name__ == '__main__':
    main()

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

def solve():
    N = int(readline())
    a = N % 1000
    if a == 0:
        print(0)
    else:
        print(1000 - a)


solve()

Solution (Python):

from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

N = int(input())

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

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

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

Solution (Python):



import itertools

def main():
    n = int(input())
    a = n % 1000
    if a > 0:
        print(1000 - a)
        exit()
    print(a)

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()

Solution (Python):


import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

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



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


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



if __name__ == "__main__":
    main()

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

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

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

n = int(input())

tmp = -(-n//1000)

print(tmp*1000-n)

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

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

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

Solution (Python):


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

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

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

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

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    if N % 1000 == 0: print(0)
    else: print(1000 - (N % 1000))

    return 0

if __name__ == "__main__":
    solve()

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

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

print(-N % 1000)

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

ans = M*1000-N
print(ans)

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

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):
a=int(input())
b=0
while a>b:
  b+=1000
print(b-a)

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

    print((100000 - N) % 1000)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
mult = (N + 999) // 1000

print(mult * 1000 - N)

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

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

Solution (Python):
from math import ceil


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


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
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())
print((1000-n%1000)%1000)

Solution (Python):


'''
Author: andyli
Time: 2020-07-05 19:56:16
'''

import os
from io import BytesIO, IOBase
import sys


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



BUFSIZE = 1048576


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


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')




if __name__ == '__main__':
    main()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
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()

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

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

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

Solution (Python):


import sys
input=sys.stdin.readline

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
a = N % 1000

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

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

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

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

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

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

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

Solution (Python):
import os
import sys
from io import BytesIO, IOBase

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")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

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

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

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

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

i = 0
while 1000 * i < n:
    i += 1
print(1000 * i - n)

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

Solution (Python):


import math; from collections import *
import sys; from functools import reduce


def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)




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

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

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

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

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

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

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

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


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

Solution (Python):
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
f = (n+999)//1000*1000
print(f-n)

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

Solution (Python):










import sys

def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]

def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)


N = iIn()
ans = -1 * N % 1000
print(ans)

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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