import re def main(): text = input() l = text.find('c') m = text.find('w', l + 1) n = text.find('w', m + 1) if text.count('c') < 1 or text.count('w') < 2: print(-1) elif text.count('c') == 1 and text.count('w') == 1: print(-1) elif l < m < n: patcww = re.compile(r'cx*?wx*?w') rescww = patcww.search(text) print(len(rescww.group())) else: print(-1) if __name__ == '__main__': main()