"use strict";
const main = arg => {
  let txt = arg.split("");
  let A = txt.indexOf("A");
  let Z = txt.lastIndexOf("Z");
  console.log(Z - A + 1);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
