func readInt() -> Int {
    return Int(readLine()!)!
}

func main() {
    let price = readInt()
    let payment = price % 1000 == 0 ? price / 1000 : price / 1000 * 1
    let exchange = payment - price
    print(exchange)
    return
}
