import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1; bills (n % 1000 == 0)?(n/1000):(n/1000)+1 (n % 1000 == 0) n % 1000 n 1000 0 (n/1000) n 1000 (n/1000)+1 (n/1000) n 1000 1 System.out.println((bills * 1000) - n) System.out.println System.out System System.out (bills * 1000) - n (bills * 1000) bills 1000 n String[] args args public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	}

} public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int bills = (n % 1000 == 0)?(n/1000):(n/1000)+1;
		
		System.out.println((bills * 1000) - n);
	}

}
