# 最小チワワ問題 str = input() count = 0 wCount = 0 ans = 0 j = 'c' for n in range(1, len(str)-1): if(str[n]=='c' and j=='c'): count+=1 j='w' elif(str[n]=='w' and j=='w' and wCount!=2): count+=1 wCount+=1 if(wCount==2): ans=count count=0 j=0 elif(j=='w'): count+=1 if(ans==0): print(-1) else: print(ans)