        import java.util.Scanner;
         
        public class Main {
         
        	public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            }
        } import java.util.Scanner; Scanner java.util public class Main {
         
        	public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            }
        } Main public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            } main {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String price = scan.nextLine(); price scan.nextLine() scan.nextLine scan scan.close() scan.close scan int otsuri = Integer.parseInt(price) % 1000; otsuri Integer.parseInt(price) % 1000 Integer.parseInt(price) Integer.parseInt Integer price 1000 if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                } otsuri == 0 otsuri 0 {
                    System.out.println(otsuri);
                } System.out.println(otsuri) System.out.println System.out System System.out otsuri {
                    System.out.println(1000 - otsuri);
                } System.out.println(1000 - otsuri) System.out.println System.out System System.out 1000 - otsuri 1000 otsuri String[] args args public class Main {
         
        	public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            }
        } public class Main {
         
        	public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            }
        } Main
        import java.util.Scanner;
         
        public class Main {
         
        	public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            }
        }