s = [] N = list(input())[::-1] if N.count("wcwc") > 0: s += 4 if N.count("wwc") > 0: s += 3 M1_flg = 1 m1 = m2 = 0 for i, n in enumerate(N): if n == "w" and M1_flg == 1: m1 = i M1_flg = 2 elif n == "w" and M1_flg == 2: m2 = i M1_flg = 3 elif n == "w" and M1_flg == 3: m1 = m2 m2 = i elif n == "c" and M1_flg == 3: s += [i - m1 + 1] m1 = i M1_flg = 1 print(min(s) if len(s) != 0 else -1)