import re s,matcher=input(),"c.*w.*w" matches=re.findall(matcher,s) if len(matches)==0: print(-1) else: matches.sort(key=lambda x:len(x)) print(len(matches[0]))