defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> pay_1000()
    |> IO.puts()
  end

  def pay_1000(mod) when mod >= 1000 do
    pay_1000(mod - 1000)
  end

  def pay_1000(mod) do
    mod
  end
  end