import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int zIndex = Integer.MIN_VALUE;
    int aIndex = Integer.MAX_VALUE;
    for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    }
    System.out.println(zIndex-aIndex+1);

    sc.close();
  }
} import java.util.*; util.* java class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int zIndex = Integer.MIN_VALUE;
    int aIndex = Integer.MAX_VALUE;
    for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    }
    System.out.println(zIndex-aIndex+1);

    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int zIndex = Integer.MIN_VALUE;
    int aIndex = Integer.MAX_VALUE;
    for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    }
    System.out.println(zIndex-aIndex+1);

    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int zIndex = Integer.MIN_VALUE;
    int aIndex = Integer.MAX_VALUE;
    for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    }
    System.out.println(zIndex-aIndex+1);

    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int zIndex = Integer.MIN_VALUE; zIndex Integer.MIN_VALUE Integer Integer.MIN_VALUE int aIndex = Integer.MAX_VALUE; aIndex Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    } {
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    } String S = String.valueOf(s.charAt(i)); S String.valueOf(s.charAt(i)) String.valueOf String s.charAt(i) s.charAt s i if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      } S.equals("A") S.equals S "A" {
        if(aIndex > i){
          aIndex = i;
        }
      } if(aIndex > i){
          aIndex = i;
        } aIndex > i aIndex i {
          aIndex = i;
        } aIndex = i aIndex i if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      } S.equals("Z") S.equals S "Z" {
        if(zIndex < i){
          zIndex = i;
        }
      } if(zIndex < i){
          zIndex = i;
        } zIndex < i zIndex i {
          zIndex = i;
        } zIndex = i zIndex i System.out.println(zIndex-aIndex+1) System.out.println System.out System System.out zIndex-aIndex+1 zIndex-aIndex zIndex aIndex 1 sc.close() sc.close sc String[] args args
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int zIndex = Integer.MIN_VALUE;
    int aIndex = Integer.MAX_VALUE;
    for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    }
    System.out.println(zIndex-aIndex+1);

    sc.close();
  }
}
