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