import java.util.*;
import java.io.*;
public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 }
} Main public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 } main {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 } Scanner in = new Scanner(System.in); in new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = in.nextInt(); n in.nextInt() in.nextInt in if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   } n % 1000 == 0 n % 1000 n 1000 0 {
     out.println(0);
   } out.println(0) out.println out 0 {
     out.println((n / 1000 + 1) * 1000 - n);
   } out.println((n / 1000 + 1) * 1000 - n) out.println out (n / 1000 + 1) * 1000 - n (n / 1000 + 1) * 1000 (n / 1000 + 1) n / 1000 n 1000 1 1000 n out.close() out.close out String agrs[] agrs public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 }
} public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 }
} Main
import java.util.*;
import java.io.*;
public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 }
}