import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  } main {
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int total = scan.nextInt(); total scan.nextInt() scan.nextInt scan int noguti = 0; noguti 0 if(total < 1000){
     System.out.print(1000- total);
    } total < 1000 total 1000 {
     System.out.print(1000- total);
    } System.out.print(1000- total) System.out.print System.out System System.out 1000- total 1000 total if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    } total > 999 && total % 1000 == 0 total > 999 total 999 total % 1000 == 0 total % 1000 total 1000 0 {
     System.out.print(0);
    } System.out.print(0) System.out.print System.out System System.out 0 if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    } total > 999 && total % 1000 != 0 total > 999 total 999 total % 1000 != 0 total % 1000 total 1000 0 {
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    } noguti = (total/1000)+ 1 noguti (total/1000)+ 1 (total/1000) total 1000 1 System.out.print(1000*noguti - total) System.out.print System.out System System.out 1000*noguti - total 1000*noguti 1000 noguti total String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int total = scan.nextInt();
    int noguti = 0;
    if(total < 1000){
     System.out.print(1000- total);
    }
    if(total > 999 && total % 1000 == 0){
     System.out.print(0);
    }
    if(total > 999 && total % 1000 != 0){
     noguti = (total/1000)+ 1;
    System.out.print(1000*noguti - total);
    }    
  }
}