import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    } main {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan scan.close() scan.close scan int money = 0; money 0 while(money < N){
            money = money + 1000;
        } money < N money N {
            money = money + 1000;
        } money = money + 1000 money money + 1000 money 1000 System.out.println(money-N) System.out.println System.out System System.out money-N money N String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.close();

        int money = 0;
        while(money < N){
            money = money + 1000;
        }
        System.out.println(money-N);
    }
}