import java.util.*;
public class Main {
  public static void main(String [] args) {
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      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.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      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.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      Z = S.lastIndexOf("Z");
      System.out.println(Z-A+1);
  } main {
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      Z = S.lastIndexOf("Z");
      System.out.println(Z-A+1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int A = 0; A 0 int Z = 0; Z 0 A = S.indexOf("A") A S.indexOf("A") S.indexOf S "A" 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.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      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.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      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.next();
      int A = 0;
      int Z = 0;
      A = S.indexOf("A");
      Z = S.lastIndexOf("Z");
      System.out.println(Z-A+1);
  }
}