
s = io.read("*l")
count = 0
ret = 0
start = false
for i = 1, #s do
	c = string.sub(s, i, i)
	if start then
		count = count + 1
		if  c == "Z" then
			ret = count
		end
	elseif c == "A" then
		start = true
		count = 1
	end
end
print(ret)