import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	} main {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1; c 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(1000 * c - n) System.out.println System.out System System.out 1000 * c - n 1000 * c 1000 c n String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	}
}