import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int payment = 0; payment 0 for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		} int i = 0; int i = 0; i 0 i < n i n i+=1000 i+=1000 i 1000 {
			payment += 1000;
		} {
			payment += 1000;
		} payment += 1000 payment 1000 int exa = payment - n; exa payment - n payment n System.out.println(exa) System.out.println System.out System System.out exa String[] args args public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	}
} public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int payment = 0;
		for (int i = 0; i < n; i+=1000) {
			payment += 1000;
		}
		int exa = payment - n;
		System.out.println(exa);
	}
}
