import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	}

}


 import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	}

} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	} main {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int p = sc.nextInt(); p sc.nextInt() sc.nextInt sc int a =1000; a 1000 int i=2; i 2 while(a<p) {
			a=1000*i;
			i++;
		} a<p a p {
			a=1000*i;
			i++;
		} a=1000*i a 1000*i 1000 i i++ i System.out.println(a-p) System.out.println System.out System System.out a-p a p String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	}

} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	}

} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	}

}



