defmodule Main do
  def connect_cities(n, m) do
    (n - 1) - m
  end
 
 def main do
    [n, m] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
    links = 1..m
                |> Enum.map(fn _ -> IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)end)
    IO.inspect connect_cities(n, m)
 end
end