import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 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();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 1000 - N);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 1000 - N);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 1000 - N);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int num = N / 1000; num N / 1000 N 1000 if (0 < N % 1000) {
            num++;
        } 0 < N % 1000 0 N % 1000 N 1000 {
            num++;
        } num++ num System.out.println(num * 1000 - N) System.out.println System.out System System.out num * 1000 - N num * 1000 num 1000 N String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 1000 - N);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 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();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 1000 - N);
    }
}