# 最小チワワ問題 str = input() wCount = 0 ans = 100 for n,sc in enumerate(str): wCount=0 length=1 if(sc=='c'): for sw in str[n+1:]: length+=1 if(sw=='w'): wCount+=1 if(wCount==2): if(ans>length): ans=length if(ans==100): print(-1) else: print(ans)