import re



s = eval(input())

list_s = [len(i) for i in re.findall("A.*Z", s)]

print((max(list_s)))
s = eval(input())



a = s.find('A')

z = s.rfind('Z')



print((z-a+1))

import re

s = eval(input())
list_s = [len(i) for i in re.findall("A.*Z", s)]
print((max(list_s)))

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

-import re - -list_s = [len(i) for i in re.findall("A.*Z", s)] -print((max(list_s))) +a = s.find("A") +z = s.rfind("Z") +print((z - a + 1))