import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    }
 
 
 
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    }
 
 
 
} Main public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    } main {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int money = 1000; money 1000 if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        } N % money == 0 N % money N money 0 {//お釣りなし
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        } money = (N/money +1)*1000 money (N/money +1)*1000 (N/money +1) N/money N money 1 1000 System.out.println(money-N) System.out.println System.out System System.out money-N money N String[] args args public class Main {
    public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    }
 
 
 
} public class Main {
    public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    }
 
 
 
} Main
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    }
 
 
 
}