import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	}
} Main public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	} main {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int input = Integer.parseInt(sc.nextLine()); input Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int amari = input % 1000; amari input % 1000 input 1000 int result = amari == 0 ? 0 : 1000 - amari; result amari == 0 ? 0 : 1000 - amari amari == 0 amari 0 0 1000 - amari 1000 amari System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	}
} public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	}
}
