s=input() a='' count=0 for i in range(len(s)): if a=='' and s[i]=='c': a+='c' count+=1 elif a=='c' and s[i]=='w': a+='w' count+=1 elif a=='cw' and s[i]=='w': a+='w' count+=1 break elif a=='c': count+=1 if count==len(s) and a!='cww': print(-1) else: print(count)