//package  com.company;

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int number=sc.nextInt();
       int val=number/1000;
       if(number%1000!=0){
           val+=1;
       }else{

       }
        System.out.println(1000*val-number);
    }
} import java.util.Scanner; Scanner java.util public class Main{

    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int number=sc.nextInt();
       int val=number/1000;
       if(number%1000!=0){
           val+=1;
       }else{

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

       }
        System.out.println(1000*val-number);
    } main {
       Scanner sc=new Scanner(System.in);
       int number=sc.nextInt();
       int val=number/1000;
       if(number%1000!=0){
           val+=1;
       }else{

       }
        System.out.println(1000*val-number);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int number=sc.nextInt(); number sc.nextInt() sc.nextInt sc int val=number/1000; val number/1000 number 1000 if(number%1000!=0){
           val+=1;
       }else{

       } number%1000!=0 number%1000 number 1000 0 {
           val+=1;
       } val+=1 val 1 {

       } System.out.println(1000*val-number) System.out.println System.out System System.out 1000*val-number 1000*val 1000 val number String[] args args public class Main{

    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int number=sc.nextInt();
       int val=number/1000;
       if(number%1000!=0){
           val+=1;
       }else{

       }
        System.out.println(1000*val-number);
    }
} public class Main{

    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int number=sc.nextInt();
       int val=number/1000;
       if(number%1000!=0){
           val+=1;
       }else{

       }
        System.out.println(1000*val-number);
    }
} Main
//package  com.company;

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int number=sc.nextInt();
       int val=number/1000;
       if(number%1000!=0){
           val+=1;
       }else{

       }
        System.out.println(1000*val-number);
    }
}