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