s = str(input()) C = [] W = [] for i, c in enumerate(s): if c == 'c': C.append(i) if c == 'w': W.append(i) import bisect INF = 10**18 ans = INF for ci in C: i = bisect.bisect_left(W, ci) if len(W)-i < 2: break ans = min(ans, W[i+1]-ci+1) if ans != INF: print(ans) else: print(-1)