import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String S = sc.next();



    int firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 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 firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 1 );


  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String S = sc.next();



    int firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 1 );


  } main {
    Scanner sc = new Scanner(System.in);

    String S = sc.next();



    int firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 1 );


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

    String S = sc.next();



    int firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 1 );


  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String S = sc.next();



    int firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 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 firstA = S.indexOf("A");
    int lastZ  = S.lastIndexOf("Z");
    System.out.println( lastZ - firstA + 1 );


  }
}
