S = input() cPos, wPos, w2Pos, minStep, temp = 0, 0, 0, [], -1 for _ in range(S.count("c")): cPos = S.find("c", temp+1) wPos = S.find("w", cPos+1) w2Pos = S.find("w", wPos+1) temp = cPos if not (cPos==-1 or wPos==-1 or w2Pos==-1): minStep.append(w2Pos - cPos + 1) print(min(minStep))