local str = io.read("*l")
local a, z = 0, 0
local flag = false
for i = 1, #str do
  local char = string.sub(str, i, i)
  if flag == false and char == "A" then
    flag = true
    a = i
  elseif char == "Z" then
    z = i
  end
end
local ans = z - a + 1
print(ans)
