import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 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();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  }

} Main public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  } main {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S_ = sc.next(); S_ sc.next() sc.next sc sc.close() sc.close sc String[] S = S_.split(""); S S_.split("") S_.split S_ "" int start = 0; start 0 for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    } int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    } {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    } if (S[i].equals("A")) {
        start = i;
        break;
      } S[i].equals("A") S[i].equals S[i] S i "A" {
        start = i;
        break;
      } start = i start i break; int end = 0; end 0 for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    } int i = S.length - 1; int i = S.length - 1; i S.length - 1 S.length S S.length 1 0 <= i 0 i i-- i-- i {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    } {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    } if (S[i].equals("Z")) {
        end = i;
        break;
      } S[i].equals("Z") S[i].equals S[i] S i "Z" {
        end = i;
        break;
      } end = i end i break; System.out.println(end - start + 1) System.out.println System.out System System.out end - start + 1 end - start end start 1 String[] args args public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  }

} public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  }

} Main
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  }

}