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