local s = io.read()

local function getAAA(str)
	local len = string.len(str)
	local p = string.find(str, "A")
	if not p then
		return 0
	end
	local p2 = string.find(str, "Z[[a-y]*[A-Y]*$")
	if not p2 then
		return 0
	end
	local n = len - p - (len - p2) + 1
	return n
end

local n = getAAA(s)
print(n)