import java.util.Scanner;

public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    }
} Main public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int ans = 0; ans 0 if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        } N < 1000 N 1000 {
            ans = 1000 - N;
        } ans = 1000 - N ans 1000 - N 1000 N if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        } N % 1000 == 0 N % 1000 N 1000 0 {
            System.out.println(0);
            System.exit(0);
        } System.out.println(0) System.out.println System.out System System.out 0 System.exit(0) System.exit System 0 {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        } String t = String.valueOf(N); t String.valueOf(N) String.valueOf String N char c = t.charAt(0); c t.charAt(0) t.charAt t 0 int thousand = Character.getNumericValue(c)*1000; thousand Character.getNumericValue(c)*1000 Character.getNumericValue(c) Character.getNumericValue Character c 1000 ans = 1000 - (N - thousand) ans 1000 - (N - thousand) 1000 (N - thousand) N thousand System.out.println(ans) System.out.println System.out System System.out ans String[] var0 var0 public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int ans = 0;

        if (N < 1000) {
            ans = 1000 - N;
        } else if (N % 1000 == 0){
            System.out.println(0);
            System.exit(0);
        } else {
            String t = String.valueOf(N);
            char c = t.charAt(0);
            int thousand = Character.getNumericValue(c)*1000;
            ans = 1000 - (N - thousand);
        }

        System.out.println(ans);
    }
}
