import java.util.Scanner;

class Main{
    static public void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int n;
      n = sc.nextInt();

      int x = (n+1000-1)/1000;
      int change = x*1000 - n;

      System.out.println(change);
      }
} import java.util.Scanner; Scanner java.util class Main{
    static public void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int n;
      n = sc.nextInt();

      int x = (n+1000-1)/1000;
      int change = x*1000 - n;

      System.out.println(change);
      }
} Main static public void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int n;
      n = sc.nextInt();

      int x = (n+1000-1)/1000;
      int change = x*1000 - n;

      System.out.println(change);
      } main {
      Scanner sc = new Scanner(System.in);

      int n;
      n = sc.nextInt();

      int x = (n+1000-1)/1000;
      int change = x*1000 - n;

      System.out.println(change);
      } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n; n n = sc.nextInt() n sc.nextInt() sc.nextInt sc int x = (n+1000-1)/1000; x (n+1000-1)/1000 (n+1000-1) n+1000 n 1000 1 1000 int change = x*1000 - n; change x*1000 - n x*1000 x 1000 n System.out.println(change) System.out.println System.out System System.out change String[] args args
import java.util.Scanner;

class Main{
    static public void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int n;
      n = sc.nextInt();

      int x = (n+1000-1)/1000;
      int change = x*1000 - n;

      System.out.println(change);
      }
}
