s = input() if s.count('c') == 0 or s.count('w') < 2: print(-1) w1 = s.find('w') wn = s.rfind('w') 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)