defmodule Main do def input, do: IO.read(:line) |> String.trim def ii, do: input() |> String.to_integer def li, do: input() |> String.split |> Enum.map(&String.to_integer/1) def digital_root(0), do: 0 def digital_root(x) when x > 0 do case rem(x, 9) do 0 -> 9 n -> n end end def main do n = ii() IO.puts digital_root(n) end end