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