cnt=0;c_check=0;w_check=0;ans=[] for i in input(): if i=='c': cnt+=1 c_check=1 elif i=='w': if c_check==0: continue if w_check==0: w_check+=1 cnt+=1 else: cnt+=1 w_check=0 c_check=0 ans.append(cnt) cnt=0 elif c_check==1: cnt+=1 print(min(ans) if ans else -1)