import sys dump = lambda *x : print(*x, file = sys.stderr) # cawwcww で 4 と返してしまう. def WA(): import re s = input() m = re.search(r'.*c.*w.*w.*?', s) dump(m) if m is None: return(-1) else: return(len(m.group(0))) s = input() n = len(s) res = 114514 for i in range(n): if s[i] != 'c': continue cnt = 0 for j in range(i+1,n): if s[j] == 'w': cnt += 1 if cnt == 2: res = min(res, j - i + 1) break if res == 114514: res = -1 print(res)