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`.
N = list(input())
ans = 0

for i in range(len(N)):
  if N[len(N)-1-i] == "Z":
    ans = len(N) - i
    break
  else:
    pass
  
  for j in range(len(N)):
    if N[j] == "A":
      ans -= (j - 1)
      break
    else:
      pass
    
print(ans)
def resolve():
    S = input()
    a = []
    z = []
    for i in range(len(S)):
        if S[i] == "A":
            a.append(i)
        elif S[i] == "Z":
            z.append(i)
    print(z[-1]-a[0]+1)
resolve()