import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		} {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner System.out.println(((n + 1000 - 1) / 1000 * 1000 - n)) System.out.println System.out System System.out ((n + 1000 - 1) / 1000 * 1000 - n) (n + 1000 - 1) / 1000 * 1000 (n + 1000 - 1) / 1000 (n + 1000 - 1) n + 1000 n 1000 1 1000 1000 n String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((n + 1000 - 1) / 1000 * 1000 - n));
		}
	}
}
