import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  }
} Main public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  } main {
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  } Scanner sc =  new Scanner(System.in); sc new Scanner(System.in) String S = sc.nextLine(); S sc.nextLine() sc.nextLine sc int a = S.indexOf("A"); a S.indexOf("A") S.indexOf S "A" int z = S.lastIndexOf("Z"); z S.lastIndexOf("Z") S.lastIndexOf S "Z" System.out.println(z-a+1) System.out.println System.out System System.out z-a+1 z-a z a 1 String[]args args public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  }
} Main
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int a = S.indexOf("A");
    int z = S.lastIndexOf("Z");
    System.out.println(z-a+1);
  }
}