import re s = input() ls = [] for i, c in enumerate(s): if c == 'c': m = re.match('c.*?w.*?w', s[i:]) if m: ls.append(len(m.group())) print(min(ls) if len(ls) > 0 else -1)