function Main (S) {
  S = S.split("\n")[0].split("");
  var stid = -1;
  var enid = -1;
  S.forEach(function (element, index) {
    if (stid == -1 && element == "A") stid = index;
    if (stid != -1 && element == "Z") enid = index;
  });
  console.log(enid - stid + 1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));