import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) int a = Integer.parseInt(reader.readLine()); a Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader int res =1000* ((a+999)/1000); res 1000* ((a+999)/1000) 1000 ((a+999)/1000) (a+999) a 999 1000 System.out.println((res-a)) System.out.println System.out System System.out (res-a) res a String[] args args public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	}
} public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	}
} Main
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	}
}
