import re S = input().strip() r = re.match(r'^.*(c.*w.*w).*$', S) try: ans = len(r.group(1)) except: ans = -1 print(ans)