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