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 = [] if S.count("cww") > 0: print(3) else: for i in S: if i == "c": if w[0] != 0 and w[1] == 0: pass else: c = indexc[0] indexc.pop(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 w = [0,0] elif i == "w" and c != "": w[0] = indexw[0] indexw.pop(0) if len(leng) <= 0: print(-1) else: print(min(leng))