import java.util.*;

public class Main {    
    public static void main(String[] args){        
        Scanner sc = new Scanner(System.in);                                
         
        String s = sc.next();
        
        int start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        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 start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        System.out.println(end - start + 1);

    }            
} Main public static void main(String[] args){        
        Scanner sc = new Scanner(System.in);                                
         
        String s = sc.next();
        
        int start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        System.out.println(end - start + 1);

    } main {        
        Scanner sc = new Scanner(System.in);                                
         
        String s = sc.next();
        
        int start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        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 start = 0; start 0 int   end = s.length() - 1; end s.length() - 1 s.length() s.length s 1 boolean flag = true; flag true for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        } {
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        } if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            } s.charAt(i) == 'A' && flag s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' flag {
                 start = i;
                 flag  = false;
            } start = i start i flag  = false flag false if(s.charAt(i) == 'Z'){
                 end  = i;
            } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
                 end  = i;
            } end  = i end i 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 start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        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 start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        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 start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        System.out.println(end - start + 1);

    }            
}
        