import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    Pattern p = Pattern.compile("A.*Z");
    Matcher m = p.matcher(s);
    m.find();
    System.out.println(m.group().length());
  }
} import java.util.*; util.* java import java.util.regex.Pattern; Pattern java.util.regex import java.util.regex.Matcher; Matcher java.util.regex class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    Pattern p = Pattern.compile("A.*Z");
    Matcher m = p.matcher(s);
    m.find();
    System.out.println(m.group().length());
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    Pattern p = Pattern.compile("A.*Z");
    Matcher m = p.matcher(s);
    m.find();
    System.out.println(m.group().length());
  } main {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    Pattern p = Pattern.compile("A.*Z");
    Matcher m = p.matcher(s);
    m.find();
    System.out.println(m.group().length());
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc Pattern p = Pattern.compile("A.*Z"); p Pattern.compile("A.*Z") Pattern.compile Pattern "A.*Z" Matcher m = p.matcher(s); m p.matcher(s) p.matcher p s m.find() m.find m System.out.println(m.group().length()) System.out.println System.out System System.out m.group().length() m.group().length m.group() m.group m String[] args args
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    Pattern p = Pattern.compile("A.*Z");
    Matcher m = p.matcher(s);
    m.find();
    System.out.println(m.group().length());
  }
}