output_description: Print the answer.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      s
attempt: #!usr/bin/env python3
  from collections import defaultdict
  from heapq import heappush, heappop
  import sys
  import math
  import bisect
  import random
  def LI(): return list(map(int, sys.stdin.readline().split()))
  def I(): return int(sys.stdin.readline())
  def LS():return list(map(list, sys.stdin.readline().split()))
  def S(): return list(sys.stdin.readline())[:-1]
  def IR(n):
      l = [None for i in range(n)]
      for i in range(n):l[i] = I()
      return l
  def LIR(n):
      l = [None for i in range(n)]
      for i in range(n):l[i] = LI()
      return l
  def SR(n):
      l = [None for i in range(n)]
      for i in range(n):l[i] = S()
      return l
  def LSR(n):
      l = [None for i in range(n)]
      for i in range(n):l[i] = SR()
      return l
  mod = 1000000007
  
  #A
  """
  x = I()
  if x < 1200:
      print("ABC")
  else:
      print("ARC")
  """
  #B
  s = input()
  n = len(s)
  for i in range(n):
      if s[i] == "A":
          for j in range(i+1,n):
              s[j] == "Z":
                  print(j-i+1)
                  quit()
  #C
  """
  x = I()
  ans = 2*(x//11)+1
  x %= 11
  if x == 0:
      ans -= 1
  if x > 6:
      ans += 1
  print(ans)
  """
  
  #D
  """
  n = I()
  a = LI()
  d = defaultdict(int)
  for i in a:
      d[i] += 1
  l = list(d.values())
  k = len(l)+sum(l)
  for i in d.keys():
      d[i] = 1
  ans = sum(list(d.values()))
  ans -= 1 if k%2 else 0
  print(ans)
  """
  #E
  
  #F
  
  #G
  
  #H
  
  #I
  
  #J
  
  #K
  
  #L
  
  #M
  
  #N
  
  #O
  
  #P
  
  #Q
  
  #R
  
  #S
  
  #T
  
problem_description: Statement
  
  Snuke has decided to construct a string that starts with `A` and ends with
  `Z`, by taking out a substring of a string s (that is, a consecutive part of
  s).
  
  Find the greatest length of the string Snuke can construct. Here, the test set
  guarantees that there always exists a substring of s that starts with `A` and
  ends with `Z`.
samples: [{"input": "QWERTYASDFZXCV", "output": "5\n    \n\nBy taking out the seventh through eleventh characters, it is possible to\nconstruct `ASDFZ`, which starts with `A` and ends with `Z`.\n\n* * *"}, {"input": "ZABCZ", "output": "4\n    \n\n* * *"}, {"input": "HASFJGHOGAKZZFEGA", "output": "12"}]