import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    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);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    System.out.println(Z - A + 1);
  }
} Main public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    System.out.println(Z - A + 1);
  } main {
    Scanner sc = new Scanner(System.in);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    System.out.println(Z - A + 1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A=0 A 0 Z=0; Z 0 String S = sc.next(); S sc.next() sc.next sc int s = S.length(); s S.length() S.length S for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    } int i=0; int i=0; i 0 i<s i s i++ i++ i {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    } {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    } if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      } S.substring(i,i+1).equals("Z") S.substring(i,i+1).equals S.substring(i,i+1) S.substring S i i+1 i 1 "Z" {
        Z= i+1;
      } Z= i+1 Z i+1 i 1 for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    } int j=0; int j=0; j 0 j<s j s j++ j++ j {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    } {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    } if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      } S.substring(j,j+1).equals("A") S.substring(j,j+1).equals S.substring(j,j+1) S.substring S j j+1 j 1 "A" {
        A= j+1;
        break;
      } A= j+1 A j+1 j 1 break; 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);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    System.out.println(Z - A + 1);
  }
} public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    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);
    int A=0, Z=0;
    String S = sc.next();
    int s = S.length();
    for(int i=0; i<s; i++) {
      if(S.substring(i,i+1).equals("Z")) {
        Z= i+1;
      }
    }
    for(int j=0; j<s; j++) {
      if(S.substring(j,j+1).equals("A")) {
        A= j+1;
        break;
      }
    }
    System.out.println(Z - A + 1);
  }
}