import re

s = eval(input())

print((len(re.findall('A.*Z', s)[0])))
import re

s = eval(input())

pattern = 'A.*Z'

print((len(re.search(pattern, s, flags=0).group())))
import re

s = eval(input())
print((len(re.findall("A.*Z", s)[0])))

import re

s = eval(input())
pattern = "A.*Z"
print((len(re.search(pattern, s, flags=0).group())))

-print((len(re.findall("A.*Z", s)[0]))) +pattern = "A.*Z" +print((len(re.search(pattern, s, flags=0).group())))