import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io 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();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String[] S = new String[s.length()]; S new String[s.length()] s.length() s.length s int a = -1; a -1 1 int length = 0; length 0 S = s.split("") S s.split("") s.split s "" for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        } {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        } if (S[i].equals("A") && a == -1) {
                a = i;
            } S[i].equals("A") && a == -1 S[i].equals("A") S[i].equals S[i] S i "A" a == -1 a -1 1 {
                a = i;
            } a = i a i if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            } S[i].equals("Z") && a != -1 S[i].equals("Z") S[i].equals S[i] S i "Z" a != -1 a -1 1 {
                length = i - a + 1;
            } length = i - a + 1 length i - a + 1 i - a i a 1 PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) out.println(length) out.println out length sc.close() sc.close sc out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] S = new String[s.length()];
        int a = -1;
        int length = 0;
        S = s.split("");

        for (int i = 0; i < s.length(); i++) {
            if (S[i].equals("A") && a == -1) {
                a = i;
            }

            if (S[i].equals("Z") && a != -1) {
                length = i - a + 1;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(length);

        sc.close();
        out.flush();
    }
}