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