import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  } main {
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s =  sc.nextLine(); s sc.nextLine() sc.nextLine sc char a = 'A'; a 'A' char b = 'Z'; b 'Z' int count1 = 0; count1 0 int count2 = 0; count2 0 int count3 = 0; count3 0 for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    } int i = 0; int i = 0; i 0 i<s.length() i s.length() s.length s ++i ++i i {
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    } {
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    } if(a!=(s.charAt(i))){
        count1 +=1;
      } a!=(s.charAt(i)) a (s.charAt(i)) s.charAt s i {
        count1 +=1;
      } count1 +=1 count1 1 if(a==(s.charAt(i))){
        break;
      } a==(s.charAt(i)) a (s.charAt(i)) s.charAt s i {
        break;
      } break; for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    } int i = 0; int i = 0; i 0 i<s.length() i s.length() s.length s ++i ++i i {
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    } {
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    } if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      } (b==(s.charAt(i))) && (count2<=i) (b==(s.charAt(i))) b (s.charAt(i)) s.charAt s i (count2<=i) count2 i {    
        
          count2=i; 
        
      } count2=i count2 i count2 +=1 count2 1 int result = count2 - count1; result count2 - count1 count2 count1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  }
}