s = str(input()) a = -1 l = [] for i in s: for n, j in enumerate(reversed(l)): j.append(i) if i == 'w': if j.count('w') == 2: if len(j) < a or a==-1: a = len(j) l.pop(n) if i == 'c': l.append([i]) print(f'{a}\n')