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

# Python 1st Try

import copy





class Problem:

    def __init__(self, stringdata):

        self.stringdata = stringdata



    def solver(self):

        strcont = copy.copy(self.stringdata)

        result = 0

        rightposition = 0

        leftposition = len(strcont)

        j = 0

        while True:

            if strcont[j] == 'A':

                rightposition = j

                break

            else:

                j = j + 1

        j = leftposition - 1

        while True:

            if strcont[j] == 'Z':

                leftposition = j

                break

            else:

                j = j - 1



        result = leftposition - rightposition + 1

        return result





if __name__ == "__main__":

    s = eval(input())

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

# 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 1st Try
import copy


class Problem:
    def __init__(self, stringdata):
        self.stringdata = stringdata

    def solver(self):
        strcont = copy.copy(self.stringdata)
        result = 0
        rightposition = 0
        leftposition = len(strcont)
        j = 0
        while True:
            if strcont[j] == "A":
                rightposition = j
                break
            else:
                j = j + 1
        j = leftposition - 1
        while True:
            if strcont[j] == "Z":
                leftposition = j
                break
            else:
                j = j - 1
        result = leftposition - rightposition + 1
        return result


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

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

-# Python 1st Try -import copy - - -class Problem: -    def __init__(self, stringdata): -        self.stringdata = stringdata - -    def solver(self): -        strcont = copy.copy(self.stringdata) -        result = 0 -        rightposition = 0 -        leftposition = len(strcont) -        j = 0 -        while True: -            if strcont[j] == "A": -                rightposition = j -                break -            else: -                j = j + 1 -        j = leftposition - 1 -        while True: -            if strcont[j] == "Z": -                leftposition = j -                break -            else: -                j = j - 1 -        result = leftposition - rightposition + 1 -        return result +# 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 -    print(("{}".format(Problem(s).solver()))) +    print(("{}".format(solver(s))))