import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] str = s.toCharArray(); str s.toCharArray() s.toCharArray s int count = 0; count 0 for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        } {
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        } if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            } str[i] == 'A' str[i] str i 'A' {
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            } for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                } int j = s.length()-1; int j = s.length()-1; j s.length()-1 s.length() s.length s 1 j > 0 j 0 j-- j-- j {
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                } {
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                } if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    } str[j] == 'Z' str[j] str j 'Z' {
                        System.out.println(j - i + 1);
                        return;
                    } System.out.println(j - i + 1) System.out.println System.out System System.out j - i + 1 j - i j i 1 return; String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        int count = 0;
        for(int i = 0;i < s.length();i++){
            if(str[i] == 'A'){
                for(int j = s.length()-1;j > 0;j--){
                    if(str[j] == 'Z'){
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    }
}
