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