def checkChiwawaLen(strin,startPos): first = strin.find("w",startPos) second = strin.find("w",first + 1) if first == -1 or second == -1: return -1 else: return second - startPos + 1 def getCharPositionList(strin,char): startPos = 0 result = [] while(True): targetPos = strin.find(char,startPos) if targetPos == -1: break result.append(targetPos) startPos = targetPos + 1 return result #inputLine = "chiwawacchichiwawac" inputLine = input() posList = getCharPositionList(inputLine,"c") result = [s for s in [checkChiwawaLen(inputLine,s) for s in posList] if s != -1] if len(result) != 0: print(min(result)) else: print(-1)