import re if __name__ == "__main__": str = raw_input() a = [] for m in re.finditer("(c.*?w.*?w)", str): a.append(m.group()) if len(a) != 0: print(min(map(len, a))) else: print(-1)