import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  } main {
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long n = scan.nextLong(); n scan.nextLong() scan.nextLong scan long g =n%1000; g n%1000 n 1000 if (g == 0){
      g = 1000;
    } g == 0 g 0 {
      g = 1000;
    } g = 1000 g 1000 System.out.println(1000-g) System.out.println System.out System System.out 1000-g 1000 g String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long g =n%1000;
    if (g == 0){
      g = 1000;
    }
    System.out.println(1000-g);
  }
}
