import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner (System.in);
     	int num = scn.nextInt();
      	num = 1000 - (num % 1000);
      	if(num % 1000 == 0)
          num = 0;
      	System.out.print(num);
      	
    }
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner (System.in);
     	int num = scn.nextInt();
      	num = 1000 - (num % 1000);
      	if(num % 1000 == 0)
          num = 0;
      	System.out.print(num);
      	
    }
} Main public static void main(String[] args) {
		Scanner scn = new Scanner (System.in);
     	int num = scn.nextInt();
      	num = 1000 - (num % 1000);
      	if(num % 1000 == 0)
          num = 0;
      	System.out.print(num);
      	
    } main {
		Scanner scn = new Scanner (System.in);
     	int num = scn.nextInt();
      	num = 1000 - (num % 1000);
      	if(num % 1000 == 0)
          num = 0;
      	System.out.print(num);
      	
    } Scanner scn = new Scanner (System.in); scn new Scanner (System.in) int num = scn.nextInt(); num scn.nextInt() scn.nextInt scn num = 1000 - (num % 1000) num 1000 - (num % 1000) 1000 (num % 1000) num 1000 if(num % 1000 == 0)
          num = 0; num % 1000 == 0 num % 1000 num 1000 0 num = 0 num 0 System.out.print(num) System.out.print System.out System System.out num String[] args args
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner (System.in);
     	int num = scn.nextInt();
      	num = 1000 - (num % 1000);
      	if(num % 1000 == 0)
          num = 0;
      	System.out.print(num);
      	
    }
}