import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    }

    private static boolean isA(char c) {
        return c == 'A';
    }

    private static boolean isZ(char c) {
        return c == 'Z';
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    }

    private static boolean isA(char c) {
        return c == 'A';
    }

    private static boolean isZ(char c) {
        return c == 'Z';
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    } main {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    } BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) String S = input.readLine(); S input.readLine() input.readLine input int APosition = 0; APosition 0 for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        } {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        } if (isA(S.charAt(i))) {
                APosition = i;
                break;
            } isA(S.charAt(i)) isA S.charAt(i) S.charAt S i {
                APosition = i;
                break;
            } APosition = i APosition i break; int ZPosition = S.length() - 1; ZPosition S.length() - 1 S.length() S.length S 1 for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        } int i = S.length() - 1; int i = S.length() - 1; i S.length() - 1 S.length() S.length S 1 i >= 0 i 0 i-- i-- i {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        } {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        } if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            } isZ(S.charAt(i)) isZ S.charAt(i) S.charAt S i {
                ZPosition = i;
                break;
            } ZPosition = i ZPosition i break; System.out.println(ZPosition-APosition+1) System.out.println System.out System System.out ZPosition-APosition+1 ZPosition-APosition ZPosition APosition 1 String[] args args private static boolean isA(char c) {
        return c == 'A';
    } isA {
        return c == 'A';
    } return c == 'A'; c == 'A' c 'A' char c c private static boolean isZ(char c) {
        return c == 'Z';
    } isZ {
        return c == 'Z';
    } return c == 'Z'; c == 'Z' c 'Z' char c c public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    }

    private static boolean isA(char c) {
        return c == 'A';
    }

    private static boolean isZ(char c) {
        return c == 'Z';
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    }

    private static boolean isA(char c) {
        return c == 'A';
    }

    private static boolean isZ(char c) {
        return c == 'Z';
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String S = input.readLine();


        int APosition = 0;
        for (int i = 0; i < S.length(); i++) {
            if (isA(S.charAt(i))) {
                APosition = i;
                break;
            }
        }

        int ZPosition = S.length() - 1;
        for (int i = S.length() - 1; i >= 0; i--) {

            if (isZ(S.charAt(i))) {
                ZPosition = i;
                break;
            }
        }

        System.out.println(ZPosition-APosition+1);
    }

    private static boolean isA(char c) {
        return c == 'A';
    }

    private static boolean isZ(char c) {
        return c == 'Z';
    }
}