import re s,matcher,patterns,res=input(),"c.*?w.*?w",[],[] for (i,c) in enumerate(s): if c=="c": patterns.append(s[i:]) print(patterns) for pattern in patterns: matches=re.findall(matcher,pattern) for match in matches: res.append(match) res.sort(key=lambda x:len(x)) print(len(res[0]))