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()


def get_z_idx(s):
    l = len(s) - 1
    for i in range(l, -1, -1):
        if s[i] == 'Z':
            z_idx = i
            break
    return z_idx


def main(s):
    a_idx = s.index('A')
    z_idx = get_z_idx(s)
    _s = s[a_idx:z_idx + 1]
    return _s


print(main(s))
s = input()


def main(s):
    a_index = 200000 
    z_index = -1
    i = 0

    for c in s:
        if c == 'A':
            a_index = min(a_index, i)
        elif c == 'Z':
            z_index = max(z_index, i)
        i += 1

    return (z_index - a_index) + 1


print(main(s))
