s = input() c = False cpos = 0 w = False li = [] for i, v in enumerate(s): if c and w: if v == "w": if cpos == 0: li.append(i - cpos + 1) else: li.append(i - cpos + 1) elif c: if v == "w": w = True else: if v == "c": cpos = i c = True if len(li) >= 1: print(min(li)) else: print('-1')