public class Main{
	public static void main(String[] args) {
		int N = new java.util.Scanner(System.in).nextInt();
		int result = -N;

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

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

		while(result< 0) {
			result += 1000;
		}
		System.out.println(result);
	} main {
		int N = new java.util.Scanner(System.in).nextInt();
		int result = -N;

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

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

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

		while(result< 0) {
			result += 1000;
		}
		System.out.println(result);
	}
}