function Main(input) {
  var s = input.split("\n")[0];
  var n = s.length;
  var start;
  var end;

  for (var i = 0; i < n; i++) {
    if (s[i] === "A") {
      start = i;
      break;
    }
  }
  for (var i = n - 1; i >= 0; i--) {
    if (s[i] === "Z") {
      end = i;
      break;
    }
  }

  console.log(end - start + 1);
}

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