s = input() wnum = 0 w1idx = 0 w2idx = 0 cww = 0 res = len(s) + 1 for i,ss in enumerate(reversed(s)): if ss == 'w': if wnum == 0: w1idx, w2idx = i, i wnum = 1 elif wnum == 1: w1idx = i wnum += 1 else: w2idx = w1idx w1idx = i elif ss == 'c': if wnum == 2: cww = i - w2idx + 1 res = min(cww, res) wnum = 0 if res > len(s): res = -1 print(res)