import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni() % 1000;
		if (N == 0) N = 1000;
		out.println(1000 - N);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
} import java.util.*; util.* java import java.io.*; io.* java class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni() % 1000;
		if (N == 0) N = 1000;
		out.println(1000 - N);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
} Main static BufferedReader f; f static PrintWriter out; out static StringTokenizer st; st public static void main(String[] args) throws IOException {
		setIO();

		int N = ni() % 1000;
		if (N == 0) N = 1000;
		out.println(1000 - N);
		
		f.close();
		out.close();
	} main {
		setIO();

		int N = ni() % 1000;
		if (N == 0) N = 1000;
		out.println(1000 - N);
		
		f.close();
		out.close();
	} setIO() setIO int N = ni() % 1000; N ni() % 1000 ni() ni 1000 if (N == 0) N = 1000; N == 0 N 0 N = 1000 N 1000 out.println(1000 - N) out.println out 1000 - N 1000 N f.close() f.close f out.close() out.close out String[] args args static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	} ni {
		return Integer.parseInt(st.nextToken());
	} return Integer.parseInt(st.nextToken()); Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st StringTokenizer st st static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	} ni {
		return Integer.parseInt(f.readLine());
	} return Integer.parseInt(f.readLine()); Integer.parseInt(f.readLine()) Integer.parseInt Integer f.readLine() f.readLine f static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	} nl {
		return new StringTokenizer(f.readLine());
	} return new StringTokenizer(f.readLine()); new StringTokenizer(f.readLine()) static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	} nia {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	} StringTokenizer st = nl(); st nl() nl int[] A = new int[N]; A new int[N] N for (int i = 0; i < N; i++)
			A[i] = ni(st); int i = 0; int i = 0; i 0 i < N i N i++ i++ i A[i] = ni(st); A[i] = ni(st) A[i] A i ni(st) ni st return A; A int N N static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	} setIn {
		f = new BufferedReader(new FileReader(s));
	} f = new BufferedReader(new FileReader(s)) f new BufferedReader(new FileReader(s)) String s s static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	} setOut {
		out = new PrintWriter(new FileWriter(s));
	} out = new PrintWriter(new FileWriter(s)) out new PrintWriter(new FileWriter(s)) String s s static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	} setIn {
		f = new BufferedReader(new InputStreamReader(System.in));
	} f = new BufferedReader(new InputStreamReader(System.in)) f new BufferedReader(new InputStreamReader(System.in)) static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	} setOut {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	} out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))) out new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))) static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	} setIO {
		setIn(s + ".in");
		setOut(s + ".out");
	} setIn(s + ".in") setIn s + ".in" s ".in" setOut(s + ".out") setOut s + ".out" s ".out" String s s static void setIO() {
		setIn();
		setOut();
	} setIO {
		setIn();
		setOut();
	} setIn() setIn setOut() setOut
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni() % 1000;
		if (N == 0) N = 1000;
		out.println(1000 - N);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}
