class Main{public static void main(String[] a){System.out.println(999-(new java.util.Scanner(System.in).nextInt()-1)%1000);}} class Main{public static void main(String[] a){System.out.println(999-(new java.util.Scanner(System.in).nextInt()-1)%1000);}} Main public static void main(String[] a){System.out.println(999-(new java.util.Scanner(System.in).nextInt()-1)%1000);} main {System.out.println(999-(new java.util.Scanner(System.in).nextInt()-1)%1000);} System.out.println(999-(new java.util.Scanner(System.in).nextInt()-1)%1000) System.out.println System.out System System.out 999-(new java.util.Scanner(System.in).nextInt()-1)%1000 999 (new java.util.Scanner(System.in).nextInt()-1)%1000 (new java.util.Scanner(System.in).nextInt()-1) new java.util.Scanner(System.in).nextInt() new java.util.Scanner(System.in).nextInt new java.util.Scanner(System.in) 1 1000 String[] a a
class Main{public static void main(String[] a){System.out.println(999-(new java.util.Scanner(System.in).nextInt()-1)%1000);}}