import re

s = eval(input())

m = re.search(r'A.*Z', s)

print((len(m.group())))
s = eval(input())

print((s.rfind('Z') - s.find('A') + 1))
import re

s = eval(input())
m = re.search(r"A.*Z", s)
print((len(m.group())))

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

-import re - -m = re.search(r"A.*Z", s) -print((len(m.group()))) +print((s.rfind("Z") - s.find("A") + 1))