import re s = input() cww_list = re.findall(r'c.*w.*w', s) if len(cww_list) == 0: msg = '-1' else: msg = len(min(cww_list, key=len)) print(msg)