import re print(max((len(s) for s in re.findall(r"X(?:YZX)*(?:YZ?)?", input())), default=0))
Z
0
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!