s = input() l = list(s) del l[:l.index('c')] if l.count('c') >= 1 and l.count('w') >= 2 and l.index('c') < l.index('w'): l.remove('w') print(len(l[l.index('c'):l.index('w')]) + 2) else: print(-1)