s = input() w = 0 ww = 0 cww = 101 for c in range(len(s)): if s[c] == 'c' and s[c:].count('w') >= 2: w = s[c:].index('w') + c ww = s[w+1:].index('w') + w + 1 if cww > ww - c + 1: cww = ww - c + 1 if cww == 101: print(-1) else: print(cww)