import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  }
}
     import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  } main {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String[] S = new String[s.length()]; S new String[s.length()] s.length() s.length s int a = -1; a -1 1 int length = 0; length 0 S = s.split("") S s.split("") s.split s "" for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    } {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    } if (S[i].equals("A") && a == -1) {
        a = i;
      } S[i].equals("A") && a == -1 S[i].equals("A") S[i].equals S[i] S i "A" a == -1 a -1 1 {
        a = i;
      } a = i a i if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      } S[i].equals("Z") && a != -1 S[i].equals("Z") S[i].equals S[i] S i "Z" a != -1 a -1 1 {
        length = i - a + 1;
      } length = i - a + 1 length i - a + 1 i - a i a 1 System.out.println(length) System.out.println System.out System System.out length String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  }
} Main
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  }
}
    