import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+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 max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+1);

    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+1);

    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+1);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int max = 0; max 0 int cnti = 0; cnti 0 int cntz = 0; cntz 0 for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        } int i = 0; int i = 0; i 0 i<s.length()-1 i s.length()-1 s.length() s.length s 1 i++ i++ i {
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        } {
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        } if(s.charAt(i)=='A'){
                cnti=i;
                break;
            } s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
                cnti=i;
                break;
            } cnti=i cnti i break; for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        } int i = s.length()-1; int i = s.length()-1; i s.length()-1 s.length() s.length s 1 i>0 i 0 i-- i-- i {
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        } {
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        } if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            } s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
                cntz=i;
                break;
            } cntz=i cntz i break; System.out.println(cntz-cnti+1) System.out.println System.out System System.out cntz-cnti+1 cntz-cnti cntz cnti 1 String[] args args public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+1);

    }
} public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+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 max = 0;
        int cnti = 0;
        int cntz = 0;

        for(int i = 0;i<s.length()-1;i++){
            if(s.charAt(i)=='A'){
                cnti=i;
                break;
            }
        }
        for(int i = s.length()-1;i>0;i--){
            if(s.charAt(i)=='Z'){
                cntz=i;
                break;
            }
        }
        System.out.println(cntz-cnti+1);

    }
}




