import java.util.*;

public class Main{
  public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  }
} Main public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int ans = sc.nextInt() % 1000; ans sc.nextInt() % 1000 sc.nextInt() sc.nextInt sc 1000 ans = (ans == 0) ? 0 : 1000 - ans ans (ans == 0) ? 0 : 1000 - ans (ans == 0) ans 0 0 1000 - ans 1000 ans System.out.println(ans) System.out.println System.out System System.out ans String aargs[] aargs public class Main{
  public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  }
} public class Main{
  public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int ans = sc.nextInt() % 1000;
    
    ans = (ans == 0) ? 0 : 1000 - ans;
    
    System.out.println(ans);
  }
}