import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    }
} Main public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    } main {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    } Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int sum=0 sum 0 tk=1000; tk 1000 int mod=n%1000; mod n%1000 n 1000 while(tk<n){
            tk=tk+1000;
        } tk<n tk n {
            tk=tk+1000;
        } tk=tk+1000 tk tk+1000 tk 1000 sum=tk-n sum tk-n tk n System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    }
} public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int sum=0,tk=1000;
        int mod=n%1000;
        while(tk<n){
            tk=tk+1000;
        }
        sum=tk-n;
        System.out.println(sum);
    }
}