public class Main {
    public static void main(String[] args) {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    }
} Main public static void main(String[] args) {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    } main {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    } int n = new java.util.Scanner(System.in).nextInt(); n new java.util.Scanner(System.in).nextInt() new java.util.Scanner(System.in).nextInt new java.util.Scanner(System.in) int a; a if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        } n % 1000 == 0 n % 1000 n 1000 0 {
            a = n / 1000;
        } a = n / 1000 a n / 1000 n 1000 {
            a = (n / 1000) + 1;
        } a = (n / 1000) + 1 a (n / 1000) + 1 (n / 1000) n 1000 1 int b = a * 1000; b a * 1000 a 1000 int result = b - n; result b - n b n System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    }
} Main
public class Main {
    public static void main(String[] args) {
        int n = new java.util.Scanner(System.in).nextInt();
        int a;
        if(n % 1000 == 0) {
            a = n / 1000;
        } else {
            a = (n / 1000) + 1;
        }
        int b = a * 1000;
        int result = b - n;
        System.out.println(result);
    }
}