import re s,matcher=input(),"c.*?w.*?w" matches=re.findall(matcher,s) if len(matches)==0: print(-1) else: temp=list(map(len,matches)) print(min(temp))