w = list(input()) c_idx = [n for n, i in enumerate(w) if i == 'c'] w_idx = [n for n, i in enumerate(w) if i == 'w'] if w[c_idx[0]:].count('w') < 2: print(-1) else: ls = [] for i in c_idx: if len([j for j in w_idx if j > i]) < 2: break else: wls = [j for j in w_idx if j > i] ls.append(wls[1] - i + 1) print(min(ls))