import java.util.*;

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

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