#AtoZString

import re

s = str(eval(input()))

S = (re.findall('A+[a-zA-z]+Z', s))

ss = S[0]

print((len(ss)))
#AtoZString

s = str(eval(input()))

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

s = str(eval(input()))
S = re.findall("A+[a-zA-z]+Z", s)
ss = S[0]
print((len(ss)))

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

-import re - -S = re.findall("A+[a-zA-z]+Z", s) -ss = S[0] -print((len(ss))) +print((s.rfind("Z") - s.find("A") + 1))