import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

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

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

  } main {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

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

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

  }
} public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'A') {
        ans = -i;
        break;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'Z') {
        ans += i;
        break;
      }
    }

    System.out.println(ans + 1);

  }
}