#-*-coding:utf-8-*-



def main():

    s = eval(input())



    for i in range(len(s)):

        if s[i] == 'A':

            start = i

            break

    for j in range(len(s)-1, -1, -1):

        if s[j] == 'Z':

            end = j

            break

    print((end - start + 1))



if __name__ == '__main__':

    main()
#-*-coding:utf-8-*-



def main():

    s = list(eval(input()))

    start = s.index('A')

    s.reverse()

    end = len(s) - s.index('Z')

    print((end - start))



if __name__ == '__main__':

    main()
# -*-coding:utf-8-*-
def main():
    s = eval(input())
    for i in range(len(s)):
        if s[i] == "A":
            start = i
            break
    for j in range(len(s) - 1, -1, -1):
        if s[j] == "Z":
            end = j
            break
    print((end - start + 1))


if __name__ == "__main__":
    main()

# -*-coding:utf-8-*-
def main():
    s = list(eval(input()))
    start = s.index("A")
    s.reverse()
    end = len(s) - s.index("Z")
    print((end - start))


if __name__ == "__main__":
    main()

-    s = eval(input()) -    for i in range(len(s)): -        if s[i] == "A": -            start = i -            break -    for j in range(len(s) - 1, -1, -1): -        if s[j] == "Z": -            end = j -            break -    print((end - start + 1)) +    s = list(eval(input())) +    start = s.index("A") +    s.reverse() +    end = len(s) - s.index("Z") +    print((end - start))