s = [] N_flg = 1 m = 0 for i, n in enumerate(input()): if n == "c": m = i N_flg = 2 elif n == "w" and N_flg == 2: N_flg = 3 elif n == "w" and N_flg == 3: s += [i - m + 1] N_flg = 1 print(min(s) if len(s) != 0 else -1)