s,r=input(),range l=len(s) a=min([min([j-i+1if s[i]+s[j]=='cw'and 'w'in s[i:j]else l+1for j in r(i,l)])for i in r(0,l)]) print((a,-1)[a>l])