N = list(input()) c = N.index("c") w = [i for i, x in enumerate(N) if x == "w"] if w.count("w") > 1 and w.count("c") > 0: if c >= w[0] or c >= w[1]: print("-1") else: print(w[1] - c + 1) else: print("-1")