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