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`.
s = input()

a_found = False
z_found = False
temp = 0
length = 0

for i in s:

  if i == "A":
    a_found = True
  elif i == "Z":
    z_found = True
    
  if z_found == True and a_found == True:
    if temp > length:
      length = temp

    if not i == "Z":
      z_found = False
      temp = 0
  
  if i == "A":
    a_found = True

  if a_found == True:
    temp += 1

  if temp > length:
    length = temp
  print(temp, a_found, z_found)
print(length)
s = input()
a_pos = s.index("A")
z_pos = s.rindex('Z')

print(z_pos + 1 - a_pos)
