import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int base = 1000;
		int ans = 0;
		for(int i=1;;i++){
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		}
		out.println(ans);
	}
}	 import java.util.*; util.* java import java.io.*; io.* java class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int base = 1000;
		int ans = 0;
		for(int i=1;;i++){
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		}
		out.println(ans);
	}
} Main public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int base = 1000;
		int ans = 0;
		for(int i=1;;i++){
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		}
		out.println(ans);
	} main {
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int base = 1000;
		int ans = 0;
		for(int i=1;;i++){
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		}
		out.println(ans);
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) PrintWriter out = new PrintWriter(System.out, true); out new PrintWriter(System.out, true) int n = in.nextInt(); n in.nextInt() in.nextInt in int base = 1000; base 1000 int ans = 0; ans 0 for(int i=1;;i++){
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		} int i=1; int i=1; i 1 i++ i++ i {
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		} {
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		} int cash = base*i; cash base*i base i if(cash >= n){
				ans = cash - n;
				break;
			} cash >= n cash n {
				ans = cash - n;
				break;
			} ans = cash - n ans cash - n cash n break; out.println(ans) out.println out ans String[]args args
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int base = 1000;
		int ans = 0;
		for(int i=1;;i++){
			int cash = base*i;
			if(cash >= n){
				ans = cash - n;
				break;
			}
		}
		out.println(ans);
	}
}	
