import java.util.Scanner;

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

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int sum = 0;
		while(sum < N) {
			sum += 1000;
		}
		System.out.println(sum - N);
	}
}
