function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  myout(input.lastIndexOf("Z") - input.indexOf("A") + 1);
}

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