import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	}

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

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	}

} Main public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	} main {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int N=scan.nextInt(); N scan.nextInt() scan.nextInt scan int s=0; s 0 s=(1000-N%1000)%1000 s (1000-N%1000)%1000 (1000-N%1000) 1000 N%1000 N 1000 1000 System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=0;
		s=(1000-N%1000)%1000;
		System.out.println(s);

	}

}