import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int number = sc.nextInt(); number sc.nextInt() sc.nextInt sc if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		} number == 10000 number 10000 {
			System.out.println(0);
			System.exit(0);
			
		} System.out.println(0) System.out.println System.out System System.out 0 System.exit(0) System.exit System 0 int ans = number/1000; ans number/1000 number 1000 if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		} number%1000 == 0 number%1000 number 1000 0 {
			System.out.println(0);
		} System.out.println(0) System.out.println System.out System System.out 0 {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		} ans = 1000-(number - ans*1000) ans 1000-(number - ans*1000) 1000 (number - ans*1000) number ans*1000 ans 1000 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		if(number == 10000) {
			System.out.println(0);
			System.exit(0);
			
		}
		int ans = number/1000;
		
		if(number%1000 == 0) {
			System.out.println(0);
		}
		else {
			ans = 1000-(number - ans*1000);
			System.out.println(ans);
		}
		
	}

}
