import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    }

} Main public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    } main {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner System.out.println((1000-(x%1000))%1000) System.out.println System.out System System.out (1000-(x%1000))%1000 (1000-(x%1000)) 1000 (x%1000) x 1000 1000 String[] args args public class Main {

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    }

} public class Main {

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println((1000-(x%1000))%1000);

    }

}
