function Main(input) {
     var line=String(input)
     var array=line.split("")
     var front=array.indexOf("A");
     var back=array.lastIndexOf("Z");
     var len=array.slice(front,back+1);
     console.log(len.length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));