import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int num = scan.nextInt(); num scan.nextInt() scan.nextInt scan int change = num%1000; change num%1000 num 1000 if(change!=0){
            change = 1000 - change;
        } change!=0 change 0 {
            change = 1000 - change;
        } change = 1000 - change change 1000 - change 1000 change System.out.println(change) System.out.println System.out System System.out change scan.close() scan.close scan String[] args args public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    }
} public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int change = num%1000;
        if(change!=0){
            change = 1000 - change;
        }
        System.out.println(change);
        scan.close();
    }
}