S = input() def solve(S): if S.count('c') == 0 or S.count('w') < 2: return -1 n = len(S) record = float('inf') for head in range(n): for tail in range(head + 1, n + 1): if has_chiwawa(S[head:tail]): if tail - head < record: record = tail - head if record == float('inf'): return -1 return record def has_chiwawa(S): c = 0 w = 0 for s in S: if s == 'c' and c == 0: c += 1 if c and s == 'w': w += 1 return w >= 2 print(solve(S))