import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    } main {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int x = in.nextInt(); x in.nextInt() in.nextInt in int bill = 0; bill 0 while (bill < x) {
            bill += 1000;
        } bill < x bill x {
            bill += 1000;
        } bill += 1000 bill 1000 System.out.println(bill - x) System.out.println System.out System System.out bill - x bill x String[] args args public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    }
} public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int bill = 0;
        while (bill < x) {
            bill += 1000;
        }
        System.out.println(bill - x);

    }
}