import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = Integer.parseInt(scan.next()); N Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int pay = 1000; pay 1000 int ans = 0; ans 0 for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		} int i = 1; int i = 1; i 1 i <= 10 i 10 i++ i++ i {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		} {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		} if (pay >=N) {
				ans = pay - N;
				break;
			} pay >=N pay N {
				ans = pay - N;
				break;
			} ans = pay - N ans pay - N pay N break; pay+=1000 pay 1000 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	}

} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int pay = 1000;
		int ans = 0;
		for (int i = 1;i <= 10 ;i++ ) {
			if (pay >=N) {
				ans = pay - N;
				break;
			}
			pay+=1000;
		}

		System.out.println(ans);
	}

}
