Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i
    elif s == 'Z':
        max_Z = i

print(max_Z - min_A)
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i + 1
    elif s == 'Z':
        max_Z = i + 1

print(max_Z - min_A + 1)