cnt=0;c_check=0;w_check=0;ans=[] s=input() for i in range(len(s)): cnt=0 c_check=0 w_check=0 for j in range(i,len(s)): if s[j]=='c': cnt+=1 c_check=1 elif s[j]=='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)