print((function (f, s) return f(s) end)(function (s) local n,a,b,c = #s+1,1,1,1 while true do a = s:find("c", a) if a == nil then break end b = s:find("w", a) if b == nil then break end c = s:find("w", b+1) if c == nil then break end if c-a+1 < n then n = c-a+1 end a = a+1 end if n > #s then n = -1 end return n end, io.stdin:read("*l")))