import itertools s = input() u = list(zip(s, range(len(s)))) ls = [z - x + 1 for (a, x), (b, y), (c, z) in itertools.product(u, repeat = 3) if (a == 'c' and b == c == 'w' and x < y < z)] if len(ls) == 0: print(-1) else: print(min(ls))