import re s = input() pat = r'c.*?w.*?w' res = re.findall(pat,s) if len(res) == 0: print(-1) else: print(len(res[0]))