public class Main{
  public static void main(String[] args){
    int n = new java.util.Scanner(System.in).nextInt();

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

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

    for (int i=0; ;i++){
      int tmp = (i+1)*1000 - n;
      if (tmp >= 0){
        System.out.println(tmp);
        break;
      }
    }
  } main {
    int n = new java.util.Scanner(System.in).nextInt();

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

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

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

    for (int i=0; ;i++){
      int tmp = (i+1)*1000 - n;
      if (tmp >= 0){
        System.out.println(tmp);
        break;
      }
    }
  }
}
