import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        } N < 1000 N 1000 {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        } out.println(1000 - N) out.println out 1000 - N 1000 N sc.close() sc.close sc out.flush() out.flush out return; int x = 0; x 0 x = (int) Math.ceil((double) N / 1000) x (int) Math.ceil((double) N / 1000) Math.ceil Math (double) N / 1000 (double) N 1000 out.println(1000 * x - N) out.println out 1000 * x - N 1000 * x 1000 x N sc.close() sc.close sc out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    }
}