public class Main {
  public static void main(String[] args) {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  }
} public class Main {
  public static void main(String[] args) {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  }
} Main public static void main(String[] args) {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  } main {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  } 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) if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    } N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000 N == 9000 N == 8000 N == 7000 N == 6000 N == 5000 N == 4000 N == 3000 N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000 N == 1000 N 1000 N == 2000 N 2000 N == 3000 N 3000 N == 4000 N 4000 N == 5000 N 5000 N == 6000 N 6000 N == 7000 N 7000 N == 8000 N 8000 N == 9000 N 9000 N == 10000 N 10000 {
      int A = 0; 
      System.out.println(A);
    } int A = 0; A 0 System.out.println(A) System.out.println System.out System System.out A {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    } int A = 1000 - (N % 1000); A 1000 - (N % 1000) 1000 (N % 1000) N 1000 System.out.println(A) System.out.println System.out System System.out A String[] args args public class Main {
  public static void main(String[] args) {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  }
} public class Main {
  public static void main(String[] args) {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  }
} Main
public class Main {
  public static void main(String[] args) {
    int N = new java.util.Scanner(System.in).nextInt();
    if (N == 1000 || N == 2000 || N == 3000 || N == 4000 || N == 5000 || N == 6000 || N == 7000 || N == 8000 || N == 9000 || N == 10000) {
      int A = 0; 
      System.out.println(A);
    } else {
      int A = 1000 - (N % 1000);
      System.out.println(A);
    }
  }
}
