import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
} 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();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	} main {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		} s.length() <= 3 s.length() s.length s 3 {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		} int n = Integer.parseInt(s); n Integer.parseInt(s) Integer.parseInt Integer s System.out.println(1000-n) System.out.println System.out System System.out 1000-n 1000 n return; s = s.substring(s.length()-3) s s.substring(s.length()-3) s.substring s s.length()-3 s.length() s.length s 3 int n = Integer.parseInt(s); n Integer.parseInt(s) Integer.parseInt Integer s if(n == 0) {
			System.out.println(0);
			return;
		} n == 0 n 0 {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; System.out.println(1000 - n) System.out.println System.out System System.out 1000 - n 1000 n String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
}
