'use strict'

function main(s) {

  const str = s.split('\n')[0];
  const first_A = str.indexOf('A');
  const last_Z  = str.lastIndexOf('Z')
  const ans = last_Z - (first_A - 1);
  console.log(ans);
}

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