import re m = re.findall('c.*?w.*?w', raw_input()) print min(map(len, m)) if m else -1