import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        while(sum < n){
            sum += 1000;
        }
        System.out.println(sum- n);

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        while(sum < n){
            sum += 1000;
        }
        System.out.println(sum- n);

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

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

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int sum = 0; sum 0 while(sum < n){
            sum += 1000;
        } sum < n sum n {
            sum += 1000;
        } sum += 1000 sum 1000 System.out.println(sum- n) System.out.println System.out System System.out sum- n sum n String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        while(sum < n){
            sum += 1000;
        }
        System.out.println(sum- n);

    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        while(sum < n){
            sum += 1000;
        }
        System.out.println(sum- n);

    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        while(sum < n){
            sum += 1000;
        }
        System.out.println(sum- n);

    }
}
