import java.util.*;
public class Main {
	public static void main(String[] args){
	    
	    
		Scanner sc = new Scanner(System.in);
        
      	String s = sc.next();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-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();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-A+1);
 
    }
} Main public static void main(String[] args){
	    
	    
		Scanner sc = new Scanner(System.in);
        
      	String s = sc.next();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-A+1);
 
    } main {
	    
	    
		Scanner sc = new Scanner(System.in);
        
      	String s = sc.next();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-A+1);
 
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String word[] =s.split(""); word s.split("") s.split s "" int i = word.length; i word.length word word.length int j =0; j 0 int A=0; A 0 int B=0; B 0 int count =0; count 0 int resultA =0; resultA 0 int resultB =0; resultB 0 while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	} B==0 && resultB==0 B==0 B 0 resultB==0 resultB 0 {
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	} i-- i if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    } word[i].equals("Z") word[i].equals word[i] word i "Z" {
      	        B=i;
      	        resultB =1;
      	    } B=i B i resultB =1 resultB 1 while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	} A==0 && resultA ==0 A==0 A 0 resultA ==0 resultA 0 {
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	} if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    } word[j].equals("A") word[j].equals word[j] word j "A" {
      	        A=j;
      	        resultA =1;
      	    } A=j A j resultA =1 resultA 1 j++ j System.out.println(B-A+1) System.out.println System.out System System.out B-A+1 B-A B A 1 String[] args args public class Main {
	public static void main(String[] args){
	    
	    
		Scanner sc = new Scanner(System.in);
        
      	String s = sc.next();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-A+1);
 
    }
} public class Main {
	public static void main(String[] args){
	    
	    
		Scanner sc = new Scanner(System.in);
        
      	String s = sc.next();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-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();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-A+1);
 
    }
}