S = input().strip() lst1 = [n for n, i in enumerate(S) if i == 'c'] lst2 = [n for n, i in enumerate(S) if i == 'w' and n > lst1[0]] if len(lst2) < 2: print(-1) exit(0) lst = [i for i in lst1 if i < lst2[0]] if len(lst) == 0: print(-1) exit(0) else: pos1 = lst[-1] pos2 = lst2[1] print(pos2 - pos1 + 1)