function Main(input){
  var s = input.split('');
  s.pop();
  var check = 0;
  for(var i=s.length-1;i>=0;i--){
    if(s[i]=='Z'){
      check=i+1;
      break;
    }
  }
  for(var i=0;i<s.length;i++){
    if(s[i]=='A'){
      check-=i+1;
      break;
    }
  }
  console.log(check+1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));