import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        }
} Main public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        } main {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        } Scanner input = new Scanner(System.in); input new Scanner(System.in) String word = input.nextLine(); word input.nextLine() input.nextLine input int n = word.length(); n word.length() word.length word int maximumLength = 0; maximumLength 0 boolean end = false; end false for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        } {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        } if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            } word.charAt(i) == 'A' word.charAt(i) word.charAt word i 'A' {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            } for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                } int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                } {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                } if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    } word.charAt(j) == 'Z' word.charAt(j) word.charAt word j 'Z' {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    } if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        } j-i+1 > maximumLength j-i+1 j-i j i 1 maximumLength {
                            maximumLength = j - i + 1;
                        } maximumLength = j - i + 1 maximumLength j - i + 1 j - i j i 1 if(j == n-1)
                        end = true; j == n-1 j n-1 n 1 end = true end true if(end)
                break; end break; System.out.println(maximumLength) System.out.println System.out System System.out maximumLength String[] args args public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        }
} public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        }
}