import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int A = S.indexOf('A');
    int Z = S.lastIndexOf('Z');
    System.out.println(Z - A + 1);
  }
} import java.util.*; util.* java import java.util.Collections; Collections java.util import java.util.stream.Collectors; Collectors java.util.stream public class Main {

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

public class Main {

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