import java.io.*;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader r = new FastReader();
        String s = r.next();

        int i, j;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        }

        for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        }

        System.out.println(j - i + 1);
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader r = new FastReader();
        String s = r.next();

        int i, j;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        }

        for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        }

        System.out.println(j - i + 1);
    }
} Main public static void main(String[] args) {
        FastReader r = new FastReader();
        String s = r.next();

        int i, j;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        }

        for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        }

        System.out.println(j - i + 1);
    } main {
        FastReader r = new FastReader();
        String s = r.next();

        int i, j;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        }

        for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        }

        System.out.println(j - i + 1);
    } FastReader r = new FastReader(); r new FastReader() String s = r.next(); s r.next() r.next r int i i j; j for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        } i = 0; i = 0 i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (s.charAt(i) == 'A')
                break;
        } {
            if (s.charAt(i) == 'A')
                break;
        } if (s.charAt(i) == 'A')
                break; s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' break; for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        } j = s.length() - 1; j = s.length() - 1 j s.length() - 1 s.length() s.length s 1 j >= 0 j 0 j-- j-- j {
            if (s.charAt(j) == 'Z')
                break;
        } {
            if (s.charAt(j) == 'Z')
                break;
        } if (s.charAt(j) == 'Z')
                break; s.charAt(j) == 'Z' s.charAt(j) s.charAt s j 'Z' break; System.out.println(j - i + 1) System.out.println System.out System System.out j - i + 1 j - i j i 1 String[] args args static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastReader {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str
import java.io.*;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader r = new FastReader();
        String s = r.next();

        int i, j;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        }

        for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        }

        System.out.println(j - i + 1);
    }
}