defmodule Main do def main do IO.read(:line) |> String.trim() |> String.to_charlist() |> solve |> IO.puts() end def solve(s) do solve_rec(s, 0, 0) end def solve_rec([], x, y) do :math.sqrt(x * x + y * y) end def solve_rec([c | t], x, y) do case c do ?N -> solve_rec(t, x, y + 1) ?E -> solve_rec(t, x + 1, y) ?W -> solve_rec(t, x - 1, y) ?S -> solve_rec(t, x, y - 1) end end end