import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	}

} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	} main {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int itemPrice = scan.nextInt(); itemPrice scan.nextInt() scan.nextInt scan while(itemPrice>0) {
			itemPrice-=1000;
		} itemPrice>0 itemPrice 0 {
			itemPrice-=1000;
		} itemPrice-=1000 itemPrice 1000 System.out.println(Math.abs(itemPrice)) System.out.println System.out System System.out Math.abs(itemPrice) Math.abs Math itemPrice String[] args args public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	}

} public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	}

} Main
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int itemPrice = scan.nextInt();
		while(itemPrice>0) {
			itemPrice-=1000;
		}
		System.out.println(Math.abs(itemPrice));

	}

}