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