import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    } main {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int calc = N % 1000; calc N % 1000 N 1000 int readyMoney = 0; readyMoney 0 if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        } calc == 0 calc 0 {
            readyMoney = 1000 * (N / 1000);
        } readyMoney = 1000 * (N / 1000) readyMoney 1000 * (N / 1000) 1000 (N / 1000) N 1000 {
            readyMoney = 1000 * (N / 1000 + 1);
        } readyMoney = 1000 * (N / 1000 + 1) readyMoney 1000 * (N / 1000 + 1) 1000 (N / 1000 + 1) N / 1000 N 1000 1 int change = readyMoney - N; change readyMoney - N readyMoney N System.out.println(change) System.out.println System.out System System.out change String[] args args public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    }
} Main
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int calc = N % 1000;
        int readyMoney = 0;
        if (calc == 0) {
            readyMoney = 1000 * (N / 1000);
        } else {
            readyMoney = 1000 * (N / 1000 + 1);
        }
        int change = readyMoney - N;
        System.out.println(change);
    }
}