"use strict";

function Main(input) {
  const a = input.indexOf("A");
  const z = input.lastIndexOf("Z");
  const inputLen = input.length;
  console.log(z-a+1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));