import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        }

    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
} import java.io.PrintWriter; PrintWriter java.io import java.math.BigDecimal; BigDecimal java.math import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        }

    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
} Main public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    } main {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    } PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Task task = new Task(); task new Task() task.solve(sc, out) task.solve task sc out out.flush() out.flush out sc.close() sc.close sc String[] args args static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    } nint {
        return Integer.parseInt(sc.next());
    } return Integer.parseInt(sc.next()); Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Scanner sc sc static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    } nlong {
        return Long.parseLong(sc.next());
    } return Long.parseLong(sc.next()); Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc Scanner sc sc static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    } ndouble {
        return Double.parseDouble(sc.next());
    } return Double.parseDouble(sc.next()); Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc Scanner sc sc static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    } nfloat {
        return Float.parseFloat(sc.next());
    } return Float.parseFloat(sc.next()); Float.parseFloat(sc.next()) Float.parseFloat Float sc.next() sc.next sc Scanner sc sc static String nstr(Scanner sc) {
        return sc.next();
    } nstr {
        return sc.next();
    } return sc.next(); sc.next() sc.next sc Scanner sc sc static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    } longLine {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    } long[] lLine = new long[size]; lLine new long[size] size for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            lLine[i] = nlong(sc);
        } {
            lLine[i] = nlong(sc);
        } lLine[i] = nlong(sc) lLine[i] lLine i nlong(sc) nlong sc return lLine; lLine Scanner sc sc int size size static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    } intLine {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    } int[] iLine = new int[size]; iLine new int[size] size for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            iLine[i] = nint(sc);
        } {
            iLine[i] = nint(sc);
        } iLine[i] = nint(sc) iLine[i] iLine i nint(sc) nint sc return iLine; iLine Scanner sc sc int size size static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    } strLine {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    } String[] strLine = new String[size]; strLine new String[size] size for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            strLine[i] = nstr(sc);
        } {
            strLine[i] = nstr(sc);
        } strLine[i] = nstr(sc) strLine[i] strLine i nstr(sc) nstr sc return strLine; strLine Scanner sc sc int size size static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    } maxFromList {
        return longList.stream().max(Comparator.naturalOrder()).get();
    } return longList.stream().max(Comparator.naturalOrder()).get(); longList.stream().max(Comparator.naturalOrder()).get() longList.stream().max(Comparator.naturalOrder()).get longList.stream().max(Comparator.naturalOrder()) longList.stream().max longList.stream() longList.stream longList Comparator.naturalOrder() Comparator.naturalOrder Comparator List<Long> longList longList static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    } minFromList {
        return longList.stream().min(Comparator.naturalOrder()).get();
    } return longList.stream().min(Comparator.naturalOrder()).get(); longList.stream().min(Comparator.naturalOrder()).get() longList.stream().min(Comparator.naturalOrder()).get longList.stream().min(Comparator.naturalOrder()) longList.stream().min longList.stream() longList.stream longList Comparator.naturalOrder() Comparator.naturalOrder Comparator List<Long> longList longList public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    } sumDigits {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    } int sum = 0; sum 0 while (n != 0) {
            sum += n % 10;
            n /= 10;
        } n != 0 n 0 {
            sum += n % 10;
            n /= 10;
        } sum += n % 10 sum n % 10 n 10 n /= 10 n 10 return sum; sum int n n public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    } sumDigits {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    } long sum = 0; sum 0 while (n != 0) {
            sum += n % 10;
            n /= 10;
        } n != 0 n 0 {
            sum += n % 10;
            n /= 10;
        } sum += n % 10 sum n % 10 n 10 n /= 10 n 10 return sum; sum long n n static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    } getIntegerList {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    } List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            list.add(nint(sc));
        } {
            list.add(nint(sc));
        } list.add(nint(sc)) list.add list nint(sc) nint sc return list; list Scanner sc sc int size size static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    } getLongList {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    } List<Long> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            list.add(nlong(sc));
        } {
            list.add(nlong(sc));
        } list.add(nlong(sc)) list.add list nlong(sc) nlong sc return list; list Scanner sc sc int size size private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    } lcm {
        return a * b / gcd(b, a % b);
    } return a * b / gcd(b, a % b); a * b / gcd(b, a % b) a * b a b gcd(b, a % b) gcd b a % b a b long a a long b b private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    } gcd {
        return b == 0 ? a : gcd(b, a % b);
    } return b == 0 ? a : gcd(b, a % b); b == 0 ? a : gcd(b, a % b) b == 0 b 0 a gcd(b, a % b) gcd b a % b a b long a a long b b static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        }

    } Task public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        } solve {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        } String s = nstr(sc); s nstr(sc) nstr sc int start = 0; start 0 int end = 0; end 0 List<Integer> sList = new ArrayList<>(); sList new ArrayList<>() while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            } true {
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            } start = s.indexOf("A", start) start s.indexOf("A", start) s.indexOf s "A" start if (start==-1){
                    break;
                } start==-1 start -1 1 {
                    break;
                } break; sList.add(start) sList.add sList start start += 1 start 1 int sm = sList.stream().min(Comparator.naturalOrder()).get(); sm sList.stream().min(Comparator.naturalOrder()).get() sList.stream().min(Comparator.naturalOrder()).get sList.stream().min(Comparator.naturalOrder()) sList.stream().min sList.stream() sList.stream sList Comparator.naturalOrder() Comparator.naturalOrder Comparator List<Integer> eList = new ArrayList<>(); eList new ArrayList<>() while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            } true {
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            } end = s.indexOf("Z", end) end s.indexOf("Z", end) s.indexOf s "Z" end if (end==-1){
                    break;
                } end==-1 end -1 1 {
                    break;
                } break; eList.add(end) eList.add eList end end += 1 end 1 int em = eList.stream().max(Comparator.naturalOrder()).get(); em eList.stream().max(Comparator.naturalOrder()).get() eList.stream().max(Comparator.naturalOrder()).get eList.stream().max(Comparator.naturalOrder()) eList.stream().max eList.stream() eList.stream eList Comparator.naturalOrder() Comparator.naturalOrder Comparator out.println(em-sm+1) out.println out em-sm+1 em-sm em sm 1 Scanner sc sc PrintWriter out out public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        }

    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
} public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        }

    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
} Main
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            String s = nstr(sc);
            int start = 0;
            int end = 0;
            List<Integer> sList = new ArrayList<>();
            while (true){
                start = s.indexOf("A", start);
                if (start==-1){
                    break;
                }
                sList.add(start);
                start += 1;
            }
            int sm = sList.stream().min(Comparator.naturalOrder()).get();
            List<Integer> eList = new ArrayList<>();
            while (true){
                end = s.indexOf("Z", end);
                if (end==-1){
                    break;
                }
                eList.add(end);
                end += 1;
            }
            int em = eList.stream().max(Comparator.naturalOrder()).get();
            out.println(em-sm+1);
        }

    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
}
