import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int len = s.length();
      
      int start = 0;
      for(int i=0; i<len; i++){
        if("A".equals(s.substring(i,i+1))){
            start = i;
            break;
        }
      }  
      int end = 0;
      for(int j=len-1; j>0; j--){
        if("Z".equals(s.substring(j,j+1))){
            end = j;
            break;
        }
      }  

      System.out.println(end-start+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 len = s.length();
      
      int start = 0;
      for(int i=0; i<len; i++){
        if("A".equals(s.substring(i,i+1))){
            start = i;
            break;
        }
      }  
      int end = 0;
      for(int j=len-1; j>0; j--){
        if("Z".equals(s.substring(j,j+1))){
            end = j;
            break;
        }
      }  

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

      System.out.println(end-start+1);
    } main {
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int len = s.length();
      
      int start = 0;
      for(int i=0; i<len; i++){
        if("A".equals(s.substring(i,i+1))){
            start = i;
            break;
        }
      }  
      int end = 0;
      for(int j=len-1; j>0; j--){
        if("Z".equals(s.substring(j,j+1))){
            end = j;
            break;
        }
      }  

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

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

      System.out.println(end-start+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 len = s.length();
      
      int start = 0;
      for(int i=0; i<len; i++){
        if("A".equals(s.substring(i,i+1))){
            start = i;
            break;
        }
      }  
      int end = 0;
      for(int j=len-1; j>0; j--){
        if("Z".equals(s.substring(j,j+1))){
            end = j;
            break;
        }
      }  

      System.out.println(end-start+1);
    }  
} 