s = input() c = [] w = [] for i in range(len(s)): if s[i] == 'c': c.append(i) for i in range(len(s)): if s[i] == 'w': w.append(i) if len(c) != 1 or len(w) < 2 or c[0] > w[0]: print(-1) else: print(w[1] - c[0] + 1)