s=input() n,m=100,0 for i in s: m+=1 if'c'==i: w=c=1 for j in s[m:]: c+=1 if'w'==j:w+=1 if w>2:n=min(n,c) print(-1if n>99 else n)