import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] price = String.valueOf(n).split(""); price String.valueOf(n).split("") String.valueOf(n).split String.valueOf(n) String.valueOf String n "" if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        } n <= 1000 n 1000 {
            System.out.println(1000 - n);
            return;
        } System.out.println(1000 - n) System.out.println System.out System System.out 1000 - n 1000 n return; if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        } Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0 Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0 Integer.parseInt(price[1]) == 0 Integer.parseInt(price[1]) Integer.parseInt Integer price[1] price 1 0 Integer.parseInt(price[2]) == 0 Integer.parseInt(price[2]) Integer.parseInt Integer price[2] price 2 0 Integer.parseInt(price[3]) == 0 Integer.parseInt(price[3]) Integer.parseInt Integer price[3] price 3 0 {
            System.out.println(0);
            return;
        } System.out.println(0) System.out.println System.out System System.out 0 return; System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n) System.out.println System.out System System.out (Integer.parseInt(price[0]) + 1) * 1000 - n (Integer.parseInt(price[0]) + 1) * 1000 (Integer.parseInt(price[0]) + 1) Integer.parseInt(price[0]) Integer.parseInt Integer price[0] price 0 1 1000 n String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] price = String.valueOf(n).split("");

        if (n <= 1000) {
            System.out.println(1000 - n);
            return;
        }

        if (Integer.parseInt(price[1]) == 0 && Integer.parseInt(price[2]) == 0 && Integer.parseInt(price[3]) == 0) {
            System.out.println(0);
            return;
        }

        System.out.println((Integer.parseInt(price[0]) + 1) * 1000 - n);
    }
}