import java.util.Scanner;

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

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

    int N = in.nextInt();
    int i = 1000;
    
	while(i<N){
      i += 1000;
    }
    
    System.out.println(i - N);
  }
} Main public static void main(String[] args){
    Scanner in = new Scanner(System.in);

    int N = in.nextInt();
    int i = 1000;
    
	while(i<N){
      i += 1000;
    }
    
    System.out.println(i - N);
  } main {
    Scanner in = new Scanner(System.in);

    int N = in.nextInt();
    int i = 1000;
    
	while(i<N){
      i += 1000;
    }
    
    System.out.println(i - N);
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int i = 1000; i 1000 while(i<N){
      i += 1000;
    } i<N i N {
      i += 1000;
    } i += 1000 i 1000 System.out.println(i - N) System.out.println System.out System System.out i - N i N String[] args args public class Main {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);

    int N = in.nextInt();
    int i = 1000;
    
	while(i<N){
      i += 1000;
    }
    
    System.out.println(i - N);
  }
} public class Main {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);

    int N = in.nextInt();
    int i = 1000;
    
	while(i<N){
      i += 1000;
    }
    
    System.out.println(i - N);
  }
} Main
import java.util.Scanner;

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

    int N = in.nextInt();
    int i = 1000;
    
	while(i<N){
      i += 1000;
    }
    
    System.out.println(i - N);
  }
}