cww = [-1, -1] cand = [-1] for i, char in enumerate(input()): if char == "c": cww[0] = i if char == "w": if cww[1] != -1: cand += [i-cww[1]+1] if cww[0] != -1: cww[1] = cww[0] print(-1 if len(cand) == 0 else min(cand))