import re l = re.findall("(?=(c.*?w.*?w))",input()) print(min(list(map(len,l))) if l else -1)