S = input().strip() min_length = float('inf') # Find all positions of 'c' c_positions = [i for i, char in enumerate(S) if char == 'c'] for i in c_positions: # Find the first 'w' after position i j = -1 for idx in range(i + 1, len(S)): if S[idx] == 'w': j = idx break if j == -1: continue # No first 'w' found # Find the second 'w' after position j k = -1 for idx in range(j + 1, len(S)): if S[idx] == 'w': k = idx break if k == -1: continue # No second 'w' found # Calculate the length of the substring current_length = k - i + 1 if current_length < min_length: min_length = current_length print(min_length if min_length != float('inf') else -1)