import java.util.*;


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


public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ansA = s.indexOf("A");
    int ansB = s.lastIndexOf("Z");
    System.out.println(ansB - ansA + 1);
  }
}
