import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc String zz = String.valueOf('Z'); zz String.valueOf('Z') String.valueOf String 'Z' String aa = String.valueOf('A'); aa String.valueOf('A') String.valueOf String 'A' int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1; ans s.lastIndexOf(zz) - s.indexOf(aa) + 1 s.lastIndexOf(zz) - s.indexOf(aa) s.lastIndexOf(zz) s.lastIndexOf s zz s.indexOf(aa) s.indexOf s aa 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String zz = String.valueOf('Z');
    String aa = String.valueOf('A');
    int ans = s.lastIndexOf(zz) - s.indexOf(aa) + 1;
    System.out.println(ans);
  }
}
