import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	} main {
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int i = 0; i 0 int count = 0; count 0 int count_commit = 0; count_commit 0 while(str.charAt(i) != 'A') i++; str.charAt(i) != 'A' str.charAt(i) str.charAt str i 'A' i++ i for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        } ; i < str.length() i str.length() str.length str i++ i++ i {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        } {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        } count++ count if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            } str.charAt(i)=='Z' str.charAt(i) str.charAt str i 'Z' {
            	count_commit += count;
            	count = 0;
            } count_commit += count count_commit count count = 0 count 0 System.out.println(count_commit) System.out.println System.out System System.out count_commit String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	}
}
