import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    }

    // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    }

}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    }

    // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    }

} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    } main {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int total = in.nextInt(); total in.nextInt() in.nextInt in int ans = thousands(total); ans thousands(total) thousands total System.out.println(ans) System.out.println System.out System System.out ans String[] args args // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    } thousands {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    } int total = 0; total 0 for (total = 1000; total < N; total = total + 1000) {
        } total = 1000; total = 1000 total 1000 total < N total N total = total + 1000 total = total + 1000 total total + 1000 total 1000 {
        } {
        } return total - N; total - N total N int N N public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    }

    // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    }

} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    }

    // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    }

    // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    }

}

