import java.util.Scanner;
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

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

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int r = N; r N while(r > 0) {
      r = r - 1000;
    } r > 0 r 0 {
      r = r - 1000;
    } r = r - 1000 r r - 1000 r 1000 System.out.println(-r) System.out.println System.out System System.out -r r String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  }
} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  }
} Main
import java.util.Scanner;
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  }
}