import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    }

} 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();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    }

} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    } main {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        } int i = 1; int i = 1; i 1 i <= 10 i 10 i++ i++ i {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        } {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        } if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            } i * 1000 >= N i * 1000 i 1000 N {
                System.out.println(i * 1000 - N);
                return;
            } System.out.println(i * 1000 - N) System.out.println System.out System System.out i * 1000 - N i * 1000 i 1000 N return; String[] args args public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    }

} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    }

} Main
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            if (i * 1000 >= N) {
                System.out.println(i * 1000 - N);
                return;
            }
        }
    }

}
