import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  }
  

  
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  }
  

  
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  } main {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int Aplace =0; Aplace 0 int Zplace =0; Zplace 0 int len = S.length(); len S.length() S.length S for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    } int i=0; int i=0; i 0 i<len i len i++ i++ i {
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    } {
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    } if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      } S.substring(i,i+1).equals("A") S.substring(i,i+1).equals S.substring(i,i+1) S.substring S i i+1 i 1 "A" {
        Aplace=i;
        break;
      } Aplace=i Aplace i break; for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    } int i=len; int i=len; i len i>0 i 0 i-- i-- i {
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    } {
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    } if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      } S.substring(i-1,i).equals("Z") S.substring(i-1,i).equals S.substring(i-1,i) S.substring S i-1 i 1 i "Z" {
        Zplace=i;
        break;
      } Zplace=i Zplace i break; System.out.println(Zplace-Aplace) System.out.println System.out System System.out Zplace-Aplace Zplace Aplace String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  }
  

  
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  }
  

  
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Aplace =0;
    int Zplace =0;
    int len = S.length();
    for(int i=0;i<len;i++){
      if(S.substring(i,i+1).equals("A")){
        Aplace=i;
        break;
      }
    }
    for(int i=len;i>0;i--){
      if(S.substring(i-1,i).equals("Z")){
        Zplace=i;
        break;
      }
    }
    System.out.println(Zplace-Aplace);
  }
  

  
}