s = input() import re r = re.findall(r'c[^cw]*w[^w]*w', s) if len(r)==0: print(-1) else: a = min([len(i) for i in r]) print(a)