s = input[::-1] if "c" in s and "w" in s: t = s[s.index("w"):s.index("c")+1] print(len(t) if t.count("w") > 1 else -1) else: print(-1)