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