import java.util.Scanner;

class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int money;
   if(n%1000 == 0){
    money = n;
   }else{
    money = ((n/1000)+1)*1000;
   }
   System.out.println(money-n);
  }
}
 import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int money;
   if(n%1000 == 0){
    money = n;
   }else{
    money = ((n/1000)+1)*1000;
   }
   System.out.println(money-n);
  }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int money;
   if(n%1000 == 0){
    money = n;
   }else{
    money = ((n/1000)+1)*1000;
   }
   System.out.println(money-n);
  } main {
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int money;
   if(n%1000 == 0){
    money = n;
   }else{
    money = ((n/1000)+1)*1000;
   }
   System.out.println(money-n);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int money; money if(n%1000 == 0){
    money = n;
   }else{
    money = ((n/1000)+1)*1000;
   } n%1000 == 0 n%1000 n 1000 0 {
    money = n;
   } money = n money n {
    money = ((n/1000)+1)*1000;
   } money = ((n/1000)+1)*1000 money ((n/1000)+1)*1000 ((n/1000)+1) (n/1000) n 1000 1 1000 System.out.println(money-n) System.out.println System.out System System.out money-n money n String[] args args
import java.util.Scanner;

class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int money;
   if(n%1000 == 0){
    money = n;
   }else{
    money = ((n/1000)+1)*1000;
   }
   System.out.println(money-n);
  }
}

