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()
ans=0
for i in range(len(s)):
  if s[i]=='A':
    for j in range(len(s)-i):
    	if s[i+j]=='Z':
          ans=i+j
print(ans)

s=input()
a=s.index('A')
ans=0
for i in range(a,len(s)):
  if s[i]=='Z':
    ans=i-a+1 if ans < i-a+1 else ans
print(ans)
