import java.util.*;

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