S = input() small = 1000 l = len(S) for i in range(l): for j in range(i+1, l): for k in range(j+1, l): if (S[i] == 'c' and S[j] == 'w' and S[k] == 'w'): small = min(small, k-i+1) if (small == 1000): print(-1) else: print(small)