# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b

# Python 2nd Try





def solver(string):

    result = 200000

    aposi = 0

    zposi = len(string)

    for j in range(0, len(string), 1):

        if string[j] == 'A':

            aposi = j

            break

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

        if string[j] == 'Z':

            zposi = j

            break

    result = zposi - aposi + 1

    return result





if __name__ == "__main__":

    s = eval(input())

    print(('{}'.format(solver(s))))

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b

# Python 3rd Try

import copy





def solver(givenstring):

    result = 0

    usestrA = copy.copy(givenstring)

    usestrZ = copy.copy(givenstring)

# a position

    apos = usestrA.index('A')+1

    usestrrevZ = usestrZ[::-1]

    zpos = len(givenstring) - usestrrevZ.index('Z')

    result = zpos - apos + 1

    return result





if __name__ == "__main__":

    s = eval(input())

    print(("{}".format(solver(s))))

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 2nd Try
def solver(string):
    result = 200000
    aposi = 0
    zposi = len(string)
    for j in range(0, len(string), 1):
        if string[j] == "A":
            aposi = j
            break
    for j in range(len(string) - 1, -1, -1):
        if string[j] == "Z":
            zposi = j
            break
    result = zposi - aposi + 1
    return result


if __name__ == "__main__":
    s = eval(input())
    print(("{}".format(solver(s))))

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 3rd Try
import copy


def solver(givenstring):
    result = 0
    usestrA = copy.copy(givenstring)
    usestrZ = copy.copy(givenstring)
    # a position
    apos = usestrA.index("A") + 1
    usestrrevZ = usestrZ[::-1]
    zpos = len(givenstring) - usestrrevZ.index("Z")
    result = zpos - apos + 1
    return result


if __name__ == "__main__":
    s = eval(input())
    print(("{}".format(solver(s))))

-# Python 2nd Try -def solver(string): -    result = 200000 -    aposi = 0 -    zposi = len(string) -    for j in range(0, len(string), 1): -        if string[j] == "A": -            aposi = j -            break -    for j in range(len(string) - 1, -1, -1): -        if string[j] == "Z": -            zposi = j -            break -    result = zposi - aposi + 1 +# Python 3rd Try +import copy + + +def solver(givenstring): +    result = 0 +    usestrA = copy.copy(givenstring) +    usestrZ = copy.copy(givenstring) +    # a position +    apos = usestrA.index("A") + 1 +    usestrrevZ = usestrZ[::-1] +    zpos = len(givenstring) - usestrrevZ.index("Z") +    result = zpos - apos + 1