import java.util.Scanner;
class Main {
  static public void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    while (a < n) {
      a += 1000;
    }
    System.out.println(a - n);
  }
} import java.util.Scanner; Scanner java.util class Main {
  static public void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    while (a < n) {
      a += 1000;
    }
    System.out.println(a - n);
  }
} Main static public void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    while (a < n) {
      a += 1000;
    }
    System.out.println(a - n);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    while (a < n) {
      a += 1000;
    }
    System.out.println(a - n);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int a = 0; a 0 while (a < n) {
      a += 1000;
    } a < n a n {
      a += 1000;
    } a += 1000 a 1000 System.out.println(a - n) System.out.println System.out System System.out a - n a n String[] args args
import java.util.Scanner;
class Main {
  static public void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    while (a < n) {
      a += 1000;
    }
    System.out.println(a - n);
  }
}
