import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	}

} Main public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	} main {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	} Scanner input =new Scanner(System.in); input new Scanner(System.in) int n=input.nextInt(); n input.nextInt() input.nextInt input int back back i i j=1; j 1 while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		} true {
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		} i=j*1000 i j*1000 j 1000 if(i>=n)
			{
				back=i-n;
				break;
			} i>=n i n {
				back=i-n;
				break;
			} back=i-n back i-n i n break; j++ j System.out.println(back) System.out.println System.out System System.out back String[] args args public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int back,i,j=1;
		while(true)
		{
			i=j*1000;
			if(i>=n)
			{
				back=i-n;
				break;
			}
			j++;
			
		}
	      System.out.println(back);

	}

}
