import java.util.*;

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

Scanner sc = new Scanner(System.in);
String s = sc.next();
int length = s.length();
int a = length;
int z = -1;
String ss;
for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
}
int ans = z - a + 1;
System.out.println(ans);

}
} import java.util.*; util.* java class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
String s = sc.next();
int length = s.length();
int a = length;
int z = -1;
String ss;
for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
}
int ans = z - a + 1;
System.out.println(ans);

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

Scanner sc = new Scanner(System.in);
String s = sc.next();
int length = s.length();
int a = length;
int z = -1;
String ss;
for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
}
int ans = z - a + 1;
System.out.println(ans);

} main {

Scanner sc = new Scanner(System.in);
String s = sc.next();
int length = s.length();
int a = length;
int z = -1;
String ss;
for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
}
int ans = z - a + 1;
System.out.println(ans);

} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int length = s.length(); length s.length() s.length s int a = length; a length int z = -1; z -1 1 String ss; ss for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
} int i = 0; int i = 0; i 0 i < length i length i++ i++ i {
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
} {
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
} ss = s.substring(i,i+1) ss s.substring(i,i+1) s.substring s i i+1 i 1 if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  } ss.equals("A") && a > i ss.equals("A") ss.equals ss "A" a > i a i {
    a = i;
  } a = i a i if(ss.equals("Z") && z < i){
    z = i;
  } ss.equals("Z") && z < i ss.equals("Z") ss.equals ss "Z" z < i z i {
    z = i;
  } z = i z i int ans = z - a + 1; ans z - a + 1 z - a z a 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

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

Scanner sc = new Scanner(System.in);
String s = sc.next();
int length = s.length();
int a = length;
int z = -1;
String ss;
for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
}
int ans = z - a + 1;
System.out.println(ans);

}
}