def myAnswer(s:str) -> int:

   start = 0

   end = 0

   for n,string in enumerate(s):

      if(string =="A"):

         start = n

         break

   for n,string in enumerate(s[::-1]):

      if(string == "Z"):

         end = len(s) - n

         break

   return end - start











def modelAnswer():

   tmp=1

def main():

   s = (eval(input()))

   print((myAnswer(s)))



if __name__ == '__main__':

   main()
def myAnswer2(s:str) -> int:

   return len(s)-s[::-1].index("Z") - s.index("A")



def main():

   s = (eval(input()))

   print((myAnswer2(s)))



if __name__ == '__main__':

   main()
def myAnswer(s: str) -> int:
    start = 0
    end = 0
    for n, string in enumerate(s):
        if string == "A":
            start = n
            break
    for n, string in enumerate(s[::-1]):
        if string == "Z":
            end = len(s) - n
            break
    return end - start


def modelAnswer():
    tmp = 1


def main():
    s = eval(input())
    print((myAnswer(s)))


if __name__ == "__main__":
    main()

def myAnswer2(s: str) -> int:
    return len(s) - s[::-1].index("Z") - s.index("A")


def main():
    s = eval(input())
    print((myAnswer2(s)))


if __name__ == "__main__":
    main()

-def myAnswer(s: str) -> int: -    start = 0 -    end = 0 -    for n, string in enumerate(s): -        if string == "A": -            start = n -            break -    for n, string in enumerate(s[::-1]): -        if string == "Z": -            end = len(s) - n -            break -    return end - start - - -def modelAnswer(): -    tmp = 1 +def myAnswer2(s: str) -> int: +    return len(s) - s[::-1].index("Z") - s.index("A") -    print((myAnswer(s))) +    print((myAnswer2(s)))