S = input() c = "" w = [0,0] indexw = [i for i, x in enumerate(S) if x == "w"] indexc = [i for i, x in enumerate(S) if x == "c"] leng = [] for i in S: if i == "c": c = indexc[0] indexc.pop(0) w = [0,0] for i in range(len(indexw)): if indexw[0] < c: indexw.pop(0) else: break elif i == "w" and w[0] != 0: w[1] = indexw[0] leng.append(w[1]-c+1) c = 0 elif i == "w" and c != "": w[0] = indexw[0] indexw.pop(0) if len(leng) <= 0: print(-1) else: print(min(leng))