public class Main{
  public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  }
} public class Main{
  public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  }
} Main public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  } main {
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  } int n = new java.util.Scanner(System.in).nextInt(); n new java.util.Scanner(System.in).nextInt() new java.util.Scanner(System.in).nextInt new java.util.Scanner(System.in) System.out.println((1000-n%1000)%1000) System.out.println System.out System System.out (1000-n%1000)%1000 (1000-n%1000) 1000 n%1000 n 1000 1000 String[] args args public class Main{
  public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  }
} public class Main{
  public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  }
} Main
public class Main{
  public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();
    System.out.println((1000-n%1000)%1000);
  }
}