import java.util.Scanner;
public class Main{
	public static void main(String[] agrs){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] agrs){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	}
} Main public static void main(String[] agrs){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	} main {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int satu = 1000; satu 1000 while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		} true {
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		} if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			} satu - n < 0 satu - n satu n 0 {
				satu += 1000;
			} satu += 1000 satu 1000 {
				System.out.print(satu - n);
				break;
			} System.out.print(satu - n) System.out.print System.out System System.out satu - n satu n break; String[] agrs agrs public class Main{
	public static void main(String[] agrs){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	}
} public class Main{
	public static void main(String[] agrs){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] agrs){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int satu = 1000;
		while(true){
			if(satu - n < 0){
				satu += 1000;
			}
			else{
				System.out.print(satu - n);
				break;
			}
		}
	}
}