
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    }
} Main public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    } main {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    } Scanner Input = new Scanner(System.in); Input new Scanner(System.in) String S = Input.next(); S Input.next() Input.next Input boolean F = false; F false int V = 0; V 0 int Max = 0; Max 0 for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        } 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' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        } {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        } if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            } S.charAt(I) == 'A' && !F S.charAt(I) == 'A' S.charAt(I) S.charAt S I 'A' !F F {
                F = true;
                V++;
            } F = true F true V++ V if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            } S.charAt(I) == 'Z' && Max <= V && F S.charAt(I) == 'Z' && Max <= V && F S.charAt(I) == 'Z' S.charAt(I) S.charAt S I 'Z' Max <= V Max V F {
                V++;
                Max = V;
            } V++ V Max = V Max V if(F){
                V++;
            } F {
                V++;
            } V++ V System.out.println(Max) System.out.println System.out System System.out Max String[] args args public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    }
} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean F = false;
        int V = 0;
        int Max = 0;
        for (int I = 0; I < S.length(); I++) {
            if (S.charAt(I) == 'A' && !F) {
                F = true;
                V++;
            } else if (S.charAt(I) == 'Z' && Max <= V && F) {
                V++;
                Max = V;
            } else if(F){
                V++;
            }
        }
        System.out.println(Max);
    }
}
