S = input() cPos, wPos, w2Pos, minStep, temp = 0, 0, 0, 0, 0 for _ in range(S.count("c")): if cPos==0 and wPos==0: cPos = S.find("c") wPos = S.find("w", cPos+1) w2Pos = S.find("w", wPos+1) temp = cPos if cPos == -1 or w2Pos == -1 or wPos==-1: minStep = -1 break minStep = w2Pos - cPos + 1 else: cPos = S.find("c", temp+1) wPos = S.find("w", temp+1) w2Pos = S.find("w", wPos+1) temp = cPos if (cPos == -1 or w2Pos == -1 or wPos==-1) and minStep==0: minStep = -1 break if minStep>w2Pos - cPos + 1 and w2Pos>cPos: minStep = w2Pos - cPos + 1 print(minStep)