string = input().rstrip("\n")

string_r = "".join(reversed(string))

print((len(string) - string_r.index("Z") - string.index("A")))
[print(len(string) - string[::-1].index("Z") - string.index("A")) for string in [input()]]

string = input().rstrip("\n")
string_r = "".join(reversed(string))
print((len(string) - string_r.index("Z") - string.index("A")))

[
    print(len(string) - string[::-1].index("Z") - string.index("A"))
    for string in [input()]
]

-string = input().rstrip("\n") -string_r = "".join(reversed(string)) -print((len(string) - string_r.index("Z") - string.index("A"))) +[ +    print(len(string) - string[::-1].index("Z") - string.index("A")) +    for string in [input()] +]