import java.util.*;

class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int ans=n%1000;
		if(ans!=0)
			ans=-ans+1000;
		System.out.println(ans);
	}
} import java.util.*; util.* java class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int ans=n%1000;
		if(ans!=0)
			ans=-ans+1000;
		System.out.println(ans);
	}
} Main public static void main(String args[]) throws Exception
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int ans=n%1000;
		if(ans!=0)
			ans=-ans+1000;
		System.out.println(ans);
	} main {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int ans=n%1000;
		if(ans!=0)
			ans=-ans+1000;
		System.out.println(ans);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int ans=n%1000; ans n%1000 n 1000 if(ans!=0)
			ans=-ans+1000; ans!=0 ans 0 ans=-ans+1000 ans -ans+1000 -ans ans 1000 System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;

class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int ans=n%1000;
		if(ans!=0)
			ans=-ans+1000;
		System.out.println(ans);
	}
}