s = input() idx_c = [] idx_w = [] l = 10**5 for i, x in enumerate(s): if x == "c": idx_c.append(i) if x == "w": idx_w.append(i) for ci in idx_c: for i in range(len(idx_w)-1): if ci < idx_w[i]: l = min(l, idx_w[i+1] - ci + 1) if l == 10**5: print(-1) else: print(l)