def main():

  s=str(eval(input()))

  l=len(s)

  f=None

  e=None

  for i in range(l):

    if s[i]=='A':

      f=i

      break

  for i in range(1,l):

    if s[-i]=='Z':

      e=l-i

      break

  print((e-f+1))

if __name__ == "__main__":

    main()
def main():

  s=str(eval(input()))

  print((s.rfind("Z") - s.find("A") + 1))

if __name__ == "__main__":

    main()
def main():
    s = str(eval(input()))
    l = len(s)
    f = None
    e = None
    for i in range(l):
        if s[i] == "A":
            f = i
            break
    for i in range(1, l):
        if s[-i] == "Z":
            e = l - i
            break
    print((e - f + 1))


if __name__ == "__main__":
    main()

def main():
    s = str(eval(input()))
    print((s.rfind("Z") - s.find("A") + 1))


if __name__ == "__main__":
    main()

-    l = len(s) -    f = None -    e = None -    for i in range(l): -        if s[i] == "A": -            f = i -            break -    for i in range(1, l): -        if s[-i] == "Z": -            e = l - i -            break -    print((e - f + 1)) +    print((s.rfind("Z") - s.find("A") + 1))