import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    }
} Main public static void main(String[] args){
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    } main {
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    } Scanner s=new Scanner(System.in); s new Scanner(System.in) int n=s.nextInt(); n s.nextInt() s.nextInt s int res=(1000-n%1000)%1000; res (1000-n%1000)%1000 (1000-n%1000) 1000 n%1000 n 1000 1000 System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main{
	public static void main(String[] args){
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int res=(1000-n%1000)%1000;
      System.out.println(res);
    }
}