defmodule Main do
  import Kernel, except: [div: 2]
  require Integer

  def main do
    [a, b] = IO.gets("") |> String.trim() |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_float(b)

    multiplication(a, b) |> IO.puts()
  end

  @doc """
  Multiplication

  ## Examples

      iex> Multiplication3.multiplication(198, 1.10)
      217
      iex> Multiplication3.multiplication(1, 0.01)
      0
      iex> Multiplication3.multiplication(1000000000000000, 9.99)
      9990000000000000

  """
  def multiplication(a, b) do
    {x, y} = mul({a, 1}, {trunc(b * 100), 1})
    |> div({100, 1})

    Kernel.div(x, y)
  end

  @doc """
  rof

  ## Examples

      iex> Multiplication3.rof({2, 4})
      {1, 2}

  """
  def rof({n, d}) do
    {Kernel.div(n, Integer.gcd(n, d)), Kernel.div(d, Integer.gcd(n, d))}
  end

  def mul({n1, d1}, {n2, d2}) do
    rof({n1 * n2, d1 * d2})
  end

  def div({n1, d1}, {n2, d2}) do
    rof({n1 * d2, d1 * n2})
  end
end