import java.util.*;

public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  }
} import java.util.*; util.* java public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  } main {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x = sc.next(); x sc.next() sc.next sc int f =0; f 0 int l =0; l 0 for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    } int i=0; int i=0; i 0 i<x.length() i x.length() x.length x i++ i++ i {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    } {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    } if (x.charAt(i) == 'A') {
        f = i;
        break;
      } x.charAt(i) == 'A' x.charAt(i) x.charAt x i 'A' {
        f = i;
        break;
      } f = i f i break; for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    } int i=x.length()-1; int i=x.length()-1; i x.length()-1 x.length() x.length x 1 i>=0 i 0 i-- i-- i {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    } {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    } if (x.charAt(i) == 'Z') {
        l = i;
        break;
      } x.charAt(i) == 'Z' x.charAt(i) x.charAt x i 'Z' {
        l = i;
        break;
      } l = i l i break; System.out.println(l-f+1) System.out.println System.out System System.out l-f+1 l-f l f 1 String[] args args public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  }
} public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  }
} Main
import java.util.*;

public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  }
}