C = input().split('c') cww = 101 for c in C: W = c.split('w') if len(W) >= 3: cww = min(cww, len(W[0] + W[1]) + 3) print(cww) if cww != 101 else print(-1)