import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    } main {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int price = scan.nextInt(); price scan.nextInt() scan.nextInt scan scan.close() scan.close scan int num1000 = price / 1000; num1000 price / 1000 price 1000 if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        } price % 1000 == 0 price % 1000 price 1000 0 {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } System.out.println("0") System.out.println System.out System System.out "0" {
            System.out.println(1000 * (num1000 + 1) - price);
        } System.out.println(1000 * (num1000 + 1) - price) System.out.println System.out System System.out 1000 * (num1000 + 1) - price 1000 * (num1000 + 1) 1000 (num1000 + 1) num1000 1 price String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    }
}