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);
  }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz