import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int bill = 1000;
        while(N>bill)
        {
            bill = bill + 1000; 
        }
        System.out.println(bill-N);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int bill = 1000;
        while(N>bill)
        {
            bill = bill + 1000; 
        }
        System.out.println(bill-N);
    }
} Main public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int bill = 1000;
        while(N>bill)
        {
            bill = bill + 1000; 
        }
        System.out.println(bill-N);
    } main {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int bill = 1000;
        while(N>bill)
        {
            bill = bill + 1000; 
        }
        System.out.println(bill-N);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int bill = 1000; bill 1000 while(N>bill)
        {
            bill = bill + 1000; 
        } N>bill N bill {
            bill = bill + 1000; 
        } bill = bill + 1000 bill bill + 1000 bill 1000 System.out.println(bill-N) System.out.println System.out System System.out bill-N bill N String args[] args
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int bill = 1000;
        while(N>bill)
        {
            bill = bill + 1000; 
        }
        System.out.println(bill-N);
    }
}