import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    }
} import java.io.IOException; IOException java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    }
} Main public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    } main {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) String whole = input.nextLine(); whole input.nextLine() input.nextLine input ArrayList<Integer> lens = new ArrayList<Integer>(); lens new ArrayList<Integer>() while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        } whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A") whole.indexOf("A") >= 0 whole.indexOf("A") whole.indexOf whole "A" 0 whole.lastIndexOf("Z") >= whole.indexOf("A") whole.lastIndexOf("Z") whole.lastIndexOf whole "Z" whole.indexOf("A") whole.indexOf whole "A" {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        } int A = whole.indexOf("A"); A whole.indexOf("A") whole.indexOf whole "A" whole = whole.substring(A) whole whole.substring(A) whole.substring whole A int Z = whole.lastIndexOf("Z"); Z whole.lastIndexOf("Z") whole.lastIndexOf whole "Z" lens.add((Z + 1)) lens.add lens (Z + 1) Z 1 whole = whole.substring(Z) whole whole.substring(Z) whole.substring whole Z int largest = 0; largest 0 for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        } int i = 0; int i = 0; i 0 i < lens.size() i lens.size() lens.size lens i++ i++ i {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        } {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        } if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            } lens.get(i) > largest lens.get(i) lens.get lens i largest {
                largest = lens.get(i);
            } largest = lens.get(i) largest lens.get(i) lens.get lens i System.out.println(largest) System.out.println System.out System System.out largest String[] args args public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    }
} public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    }
} Main
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    }
}