import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+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();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  }
} Main public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  } main {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int s = S.length(); s S.length() S.length S int a = -1 a -1 1 z = 0; z 0 for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    } int i = 0; int i = 0; i 0 i < s i s i++ i++ i {
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    } {
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    } if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      } S.charAt(i) == 'A' && a == -1 S.charAt(i) == 'A' S.charAt(i) S.charAt S i 'A' a == -1 a -1 1 {
        a = i;
      } a = i a i if(S.charAt(i) == 'Z'){
        z = i;
      } S.charAt(i) == 'Z' S.charAt(i) S.charAt S i 'Z' {
        z = i;
      } z = i z i System.out.println(z-a+1) System.out.println System.out System System.out z-a+1 z-a z a 1 String[]args args public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  }
}