import java.util.*;

public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  }  
} import java.util.*; util.* java public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  }  
} Main public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  } main {
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc char[] list = new char[str.length()]; list new char[str.length()] str.length() str.length str for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str ++i ++i i {
      list[i] = str.charAt(i);
    } {
      list[i] = str.charAt(i);
    } list[i] = str.charAt(i) list[i] list i str.charAt(i) str.charAt str i int num1 = 0; num1 0 int num2 = 0; num2 0 for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     } int i = 0; int i = 0; i 0 i < list.length i list.length list list.length ++i ++i i {
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     } {
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     } char m = list[i]; m list[i] list i if(m == 'A'){
        num1 = i;
        break;
      } m == 'A' m 'A' {
        num1 = i;
        break;
      } num1 = i num1 i break; for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    } int i = 0; int i = 0; i 0 i < list.length i list.length list list.length ++i ++i i {
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    } {
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    } char v = list[i]; v list[i] list i if(v == 'Z' && num2 < i){
        num2 = i;
      } v == 'Z' && num2 < i v == 'Z' v 'Z' num2 < i num2 i {
        num2 = i;
      } num2 = i num2 i int count = 0; count 0 for(int i = num1; i <= num2; ++i){
      count++;
    } int i = num1; int i = num1; i num1 i <= num2 i num2 ++i ++i i {
      count++;
    } {
      count++;
    } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  }  
} public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  }  
} Main
import java.util.*;

public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  }  
}
