
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    }
} Main public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    } main {
        solve(System.in, System.out);
    } solve(System.in, System.out) solve System.in System System.in System.out System System.out String[] args args static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    } solve {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    } Scanner scan = new Scanner(is); scan new Scanner(is) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        } int i = 1; int i = 1; i 1 i <= 10 i 10 i++ i++ i {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        } {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        } if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            } 1000 * i >= N 1000 * i 1000 i N {
                os.println(1000*i-N);
                return;
            } os.println(1000*i-N) os.println os 1000*i-N 1000*i 1000 i N return; InputStream is is PrintStream os os public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    }
} Main

import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 10; i++) {
            if(1000 * i >= N){
                os.println(1000*i-N);
                return;
            }
        }
    }
}