import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc sc.close() sc.close sc for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		} int i = 1; int i = 1; i 1 i <= 10 i 10 i++ i++ i {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		} {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		} int answer = 0; answer 0 answer = i*1000 - N answer i*1000 - N i*1000 i 1000 N if(answer >= 0) {
				System.out.println(answer);
				break;
			} answer >= 0 answer 0 {
				System.out.println(answer);
				break;
			} System.out.println(answer) System.out.println System.out System System.out answer break; String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	}
}
