S=input() ans = float('inf') for i in range(len(S)): for j in range(i,len(S)+1): k = S[i:j] if k.count('c') >= 1 and k.count('w') >= 2: ans = min(ans, len(k)) if ans > len(S): ans = -1 print(ans)