import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    }
  
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    }
  
} Main public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    } main {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int inputStr = scan.nextInt(); inputStr scan.nextInt() scan.nextInt scan int money = 0; money 0 int otsuri = 0; otsuri 0 for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      } int i=1; int i=1; i 1 i<=10 i 10 i++ i++ i {
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      } {
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      } money = 1000*i money 1000*i 1000 i if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        } money-inputStr >= 0 money-inputStr money inputStr 0 {
           otsuri = money-inputStr;
           break;
        } otsuri = money-inputStr otsuri money-inputStr money inputStr break; System.out.println(otsuri) System.out.println System.out System System.out otsuri final String[] args args public class Main {

    public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    }
  
} public class Main {

    public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    }
  
} Main
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    }
  
}