import java.util.*;

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

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

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

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int x = n / 1000; x n / 1000 n 1000 if(n % 1000 != 0){
            x++;
        } n % 1000 != 0 n % 1000 n 1000 0 {
            x++;
        } x++ x System.out.println(x * 1000 - n) System.out.println System.out System System.out x * 1000 - n x * 1000 x 1000 n String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

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

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

    }
} Main
import java.util.*;

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

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

    }
}
