import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

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

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

    } main {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int num = 0; num 0 if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        } N % 1000 != 0 N % 1000 N 1000 0 {
        	num = 1000 - N % 1000;
        } num = 1000 - N % 1000 num 1000 - N % 1000 1000 N % 1000 N 1000 System.out.println(num) System.out.println System.out System System.out num 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 num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

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

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int num = 0;

        if(N % 1000 != 0) {
        	num = 1000 - N % 1000;
        }

        System.out.println(num);

    }
}