import re s = input() match = re.findall(r'c[^cw]*w[^cw]*w', s) res = -1 min = 101 for i in range(len(match)): if min > len(match[i]): min = len(match[i]) if min != 101: print(min) else: print(res)