cnt=0;c_check=0;w_check=0;ans=0 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+=cnt cnt=0 elif c_check==1: cnt+=1 print(ans if ans else -1)