import re obj = re.search("c[^cw]*w.*?w",input()) if obj: print(obj.span()[1]-obj.span()[0]) else: print(-1)