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