import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} Main public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } int price = Integer.parseInt(reader.readLine()); price Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader reader.close() reader.close reader 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) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} public class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            int price = Integer.parseInt(reader.readLine());
            reader.close();
            int num1000 = price / 1000; // 必要な1000円の枚数-1
            if (price % 1000 == 0) {
                // 価格が1000円で割り切れるときはお釣り０
                System.out.println("0");
            } else {
                System.out.println(1000 * (num1000 + 1) - price);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}