import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    abc173_a();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // public static void abc000_a() {
  // try (Scanner sc = new Scanner(System.in)) {
  //
  // System.out.println("テスト");
  // } catch (Exception e) {
  // System.out.println("エラー" + e);
  // }
  // }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    abc173_a();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // public static void abc000_a() {
  // try (Scanner sc = new Scanner(System.in)) {
  //
  // System.out.println("テスト");
  // } catch (Exception e) {
  // System.out.println("エラー" + e);
  // }
  // }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
} Main public static void main(String[] args) {
    abc173_a();
  } main {
    abc173_a();
  } abc173_a() abc173_a String[] args args public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  } abc173_a {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  } try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    } Exception e {
      System.out.println("エラー" + e);
    } System.out.println("エラー" + e) System.out.println System.out System System.out "エラー" + e "エラー" e {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int payment = parseI(sc.next()); payment parseI(sc.next()) parseI sc.next() sc.next sc int max = 10000; max 10000 int thou = 1000; thou 1000 System.out.println((max - payment) % thou) System.out.println System.out System System.out (max - payment) % thou (max - payment) max payment thou public static int parseI(String value) {
    return Integer.parseInt(value);
  } parseI {
    return Integer.parseInt(value);
  } return Integer.parseInt(value); Integer.parseInt(value) Integer.parseInt Integer value String value value public class Main {

  public static void main(String[] args) {
    abc173_a();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // public static void abc000_a() {
  // try (Scanner sc = new Scanner(System.in)) {
  //
  // System.out.println("テスト");
  // } catch (Exception e) {
  // System.out.println("エラー" + e);
  // }
  // }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
} public class Main {

  public static void main(String[] args) {
    abc173_a();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // public static void abc000_a() {
  // try (Scanner sc = new Scanner(System.in)) {
  //
  // System.out.println("テスト");
  // } catch (Exception e) {
  // System.out.println("エラー" + e);
  // }
  // }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    abc173_a();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // public static void abc000_a() {
  // try (Scanner sc = new Scanner(System.in)) {
  //
  // System.out.println("テスト");
  // } catch (Exception e) {
  // System.out.println("エラー" + e);
  // }
  // }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
}
