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

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+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 a = sc.nextLine();

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+1);
        }
        System.out.println(answer);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+1);
        }
        System.out.println(answer);
    } main {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+1);
        }
        System.out.println(answer);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.nextLine(); a sc.nextLine() sc.nextLine sc int flag = 0; flag 0 int placeA = 0; placeA 0 for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i<a.length() i a.length() a.length a i++ i++ i {
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        } {
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        } if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            } a.charAt(i) == 'A' a.charAt(i) a.charAt a i 'A' {
                placeA = i;
                break;
            } placeA = i placeA i break; int[] placeB = new int[a.length()]; placeB new int[a.length()] a.length() a.length a for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        } int i =0; int i =0; i 0 i<a.length() i a.length() a.length a i++ i++ i {
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        } {
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        } if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            } a.charAt(i) == 'Z' a.charAt(i) a.charAt a i 'Z' {
                placeB[flag] = i;
                flag++;
            } placeB[flag] = i placeB[flag] placeB flag i flag++ flag int answer = 0; answer 0 for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+1);
        } int i = 0; int i = 0; i 0 i<a.length() i a.length() a.length a i++ i++ i {
                    answer = Math.max(answer,placeB[i]-placeA+1);
        } {
                    answer = Math.max(answer,placeB[i]-placeA+1);
        } answer = Math.max(answer,placeB[i]-placeA+1) answer Math.max(answer,placeB[i]-placeA+1) Math.max Math answer placeB[i]-placeA+1 placeB[i]-placeA placeB[i] placeB i placeA 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 a = sc.nextLine();

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+1);
        }
        System.out.println(answer);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+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 a = sc.nextLine();

        int flag = 0;
        int placeA = 0;
        for(int i = 0;i<a.length();i++){
            if(a.charAt(i) == 'A'){
                placeA = i;
                break;
            }
        }
        int[] placeB = new int[a.length()];
        for(int i =0;i<a.length();i++){
            if(a.charAt(i) == 'Z'){
                placeB[flag] = i;
                flag++;
            }
        }
        int answer = 0;
        for(int i = 0;i<a.length();i++){
                    answer = Math.max(answer,placeB[i]-placeA+1);
        }
        System.out.println(answer);
    }
}