import java.util.*;
public class Main {
	public static void main(String[] args) {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	}
} Main public static void main(String[] args) {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	} main {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	} System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000) System.out.println System.out System System.out (100000 - new Scanner(System.in).nextInt()) % 1000 (100000 - new Scanner(System.in).nextInt()) 100000 new Scanner(System.in).nextInt() new Scanner(System.in).nextInt new Scanner(System.in) 1000 String[] args args public class Main {
	public static void main(String[] args) {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	}
} public class Main {
	public static void main(String[] args) {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		System.out.println((100000 - new Scanner(System.in).nextInt()) % 1000);
	}
}