s = input() s += 'x' l = [] count = 0 temp = '' min = 101 for i in range(len(s)): count = 0 temp = '' if s[i] == 'c': for j in range(i, len(s)): temp += s[j] if s[j] == 'w': count += 1 if count == 2: break l.append(temp) for i in l: if i.count('w') == 2 and len(i) < min: min = len(i) if not min == 101: print(min) else: print(-1)