import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } 
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } 
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } main {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Integer price = sc.nextInt(); price sc.nextInt() sc.nextInt sc sc.close() sc.close sc int change = 0; change 0 for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        } int i = 1; int i = 1; i 1 i++ i++ i {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        } {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        } if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            } i * 1000 - price >= 0 i * 1000 - price i * 1000 i 1000 price 0 {
                change = i * 1000 - price;
                break;
            } change = i * 1000 - price change i * 1000 - price i * 1000 i 1000 price break; System.out.println(change) System.out.println System.out System System.out change String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } 
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } 
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer price = sc.nextInt();
        sc.close();
        int change = 0;
        for (int i = 1; ; i++) {
            if (i * 1000 - price >= 0) {
                change = i * 1000 - price;
                break;
            }
        }
        System.out.println(change);
    } 
}