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