import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  }
  
}

class BalanceCalculator {
  private static final int AMOUNT_PER_BILL = 1_000;
  public int pay(int price) {
    int bills = price / AMOUNT_PER_BILL;
    if (bills * AMOUNT_PER_BILL < price) {
      bills++;
    }
    return bills * AMOUNT_PER_BILL - price;
  }
}

class PriceReader {
  public int read() {
    Scanner scanner = new Scanner(System.in);
    return scanner.nextInt();
  }
}

class BalancePrinter {
  public void write(int balance) {
    System.out.println(balance);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  }
  
} Main public static void main(String[] args) {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  } main {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  } final int price = new PriceReader().read(); price new PriceReader().read() new PriceReader().read new PriceReader() final int balance = new BalanceCalculator().pay(price); balance new BalanceCalculator().pay(price) new BalanceCalculator().pay new BalanceCalculator() price new BalancePrinter().write(balance) new BalancePrinter().write new BalancePrinter() balance String[] args args class BalanceCalculator {
  private static final int AMOUNT_PER_BILL = 1_000;
  public int pay(int price) {
    int bills = price / AMOUNT_PER_BILL;
    if (bills * AMOUNT_PER_BILL < price) {
      bills++;
    }
    return bills * AMOUNT_PER_BILL - price;
  }
} BalanceCalculator private static final int AMOUNT_PER_BILL = 1_000; AMOUNT_PER_BILL 1_000 public int pay(int price) {
    int bills = price / AMOUNT_PER_BILL;
    if (bills * AMOUNT_PER_BILL < price) {
      bills++;
    }
    return bills * AMOUNT_PER_BILL - price;
  } pay {
    int bills = price / AMOUNT_PER_BILL;
    if (bills * AMOUNT_PER_BILL < price) {
      bills++;
    }
    return bills * AMOUNT_PER_BILL - price;
  } int bills = price / AMOUNT_PER_BILL; bills price / AMOUNT_PER_BILL price AMOUNT_PER_BILL if (bills * AMOUNT_PER_BILL < price) {
      bills++;
    } bills * AMOUNT_PER_BILL < price bills * AMOUNT_PER_BILL bills AMOUNT_PER_BILL price {
      bills++;
    } bills++ bills return bills * AMOUNT_PER_BILL - price; bills * AMOUNT_PER_BILL - price bills * AMOUNT_PER_BILL bills AMOUNT_PER_BILL price int price price class PriceReader {
  public int read() {
    Scanner scanner = new Scanner(System.in);
    return scanner.nextInt();
  }
} PriceReader public int read() {
    Scanner scanner = new Scanner(System.in);
    return scanner.nextInt();
  } read {
    Scanner scanner = new Scanner(System.in);
    return scanner.nextInt();
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) return scanner.nextInt(); scanner.nextInt() scanner.nextInt scanner class BalancePrinter {
  public void write(int balance) {
    System.out.println(balance);
  }
} BalancePrinter public void write(int balance) {
    System.out.println(balance);
  } write {
    System.out.println(balance);
  } System.out.println(balance) System.out.println System.out System System.out balance int balance balance public class Main {
  public static void main(String[] args) {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  }
  
} public class Main {
  public static void main(String[] args) {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  }
  
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final int price = new PriceReader().read();
    final int balance = new BalanceCalculator().pay(price);
    new BalancePrinter().write(balance);
  }
  
}

class BalanceCalculator {
  private static final int AMOUNT_PER_BILL = 1_000;
  public int pay(int price) {
    int bills = price / AMOUNT_PER_BILL;
    if (bills * AMOUNT_PER_BILL < price) {
      bills++;
    }
    return bills * AMOUNT_PER_BILL - price;
  }
}

class PriceReader {
  public int read() {
    Scanner scanner = new Scanner(System.in);
    return scanner.nextInt();
  }
}

class BalancePrinter {
  public void write(int balance) {
    System.out.println(balance);
  }
}
