import java.io.*;
class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine().trim());
    int a = 1000;
    while(a<n){
      a = a+1000;
	 // System.out.println("Executed");
	}
    a = a - n;
    System.out.println(a);
  }
} import java.io.*; io.* java class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine().trim());
    int a = 1000;
    while(a<n){
      a = a+1000;
	 // System.out.println("Executed");
	}
    a = a - n;
    System.out.println(a);
  }
} Main public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine().trim());
    int a = 1000;
    while(a<n){
      a = a+1000;
	 // System.out.println("Executed");
	}
    a = a - n;
    System.out.println(a);
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine().trim());
    int a = 1000;
    while(a<n){
      a = a+1000;
	 // System.out.println("Executed");
	}
    a = a - n;
    System.out.println(a);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine().trim()); n Integer.parseInt(br.readLine().trim()) Integer.parseInt Integer br.readLine().trim() br.readLine().trim br.readLine() br.readLine br int a = 1000; a 1000 while(a<n){
      a = a+1000;
	 // System.out.println("Executed");
	} a<n a n {
      a = a+1000;
	 // System.out.println("Executed");
	} a = a+1000 a a+1000 a 1000 a = a - n a a - n a n System.out.println(a) System.out.println System.out System System.out a String[] args args
import java.io.*;
class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine().trim());
    int a = 1000;
    while(a<n){
      a = a+1000;
	 // System.out.println("Executed");
	}
    a = a - n;
    System.out.println(a);
  }
}