defmodule Main do def main do IO.read(:line) |> String.trim() |> solve |> IO.puts() end def solve(s) do s |> String.to_charlist() |> solve_rec(0, 0, 0) end def solve_rec([], _a, _ab, abb) do abb end def solve_rec([h | t], a, ab, abb) when h == ?c do solve_rec(t, a + 1, ab, abb) end def solve_rec([h | t], a, ab, abb) when h == ?w do solve_rec(t, a, ab + a, abb + ab) end def solve_rec([_h | t], a, ab, abb) do solve_rec(t, a, ab, abb) end end