import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 1000;
        if (a != 0)
            a = 1000 - a;

        System.out.println(a);

    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 1000;
        if (a != 0)
            a = 1000 - a;

        System.out.println(a);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 1000;
        if (a != 0)
            a = 1000 - a;

        System.out.println(a);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 1000;
        if (a != 0)
            a = 1000 - a;

        System.out.println(a);

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

        System.out.println(a);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 1000;
        if (a != 0)
            a = 1000 - a;

        System.out.println(a);

    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 1000;
        if (a != 0)
            a = 1000 - a;

        System.out.println(a);

    }
}