s,r=input(),range l=len(s) a=min([min([(l+1,j-i+1)[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])