import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  }
}

 import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  }
} Main public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  } main {
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int start = s.indexOf("A"); start s.indexOf("A") s.indexOf s "A" int end   = s.lastIndexOf("Z"); end s.lastIndexOf("Z") s.lastIndexOf s "Z" int length = end + 1 - start; length end + 1 - start end + 1 end 1 start System.out.println(length) System.out.println System.out System System.out length String[] args args public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  }
} public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  }
} Main
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int start = s.indexOf("A");
    int end   = s.lastIndexOf("Z");
    int length = end + 1 - start;
    System.out.println(length);    
  }
}


