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

function Main(args){
    var input = args.split("\n");
    var tmp = input[0];
    var posA = tmp.indexOf('A');
    var posZ = tmp.lastIndexOf('Z');

    console.log( posZ - posA + 1 );
}