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