function main(input) {
  let APosition = input.indexOf('A');
  let ZPosition = input.lastIndexOf('Z');
  console.log(ZPosition - APosition + 1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));