import re S=input() l=re.findall('c[a-z]*?w[a-z]*?w',S) m=[] for i in l: m.append(len(i)) if len(m)==0: print(-1) else: print(min(m))