import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    }
} Main public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    } main {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    } try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        } {
            System.out.println(new Main().run(sc));
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) System.out.println(new Main().run(sc)) System.out.println System.out System System.out new Main().run(sc) new Main().run new Main() sc String[] args args public String run(Scanner sc) {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    } run {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    } int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int i = 1; i 1 while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        } true {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        } int payment = i * 1000; payment i * 1000 i 1000 if (payment >= n) {
                return String.valueOf(payment - n);
            } payment >= n payment n {
                return String.valueOf(payment - n);
            } return String.valueOf(payment - n); String.valueOf(payment - n) String.valueOf String payment - n payment n i++ i Scanner sc sc public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    }
} public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        int n = Integer.parseInt(sc.nextLine());
        int i = 1;
        while (true) {
            int payment = i * 1000;
            if (payment >= n) {
                return String.valueOf(payment - n);
            }
            i++;
        }
    }
}
