print((function (f, s) return f(s) end)(function (s) local r = #s+1 for e in s:gmatch("c[^c]-w[^w]-w") do if #e < r then r = #e end end if r > #s then r = -1 end return r end, io.stdin:read("*l")))