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

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    }
} Main public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    } main {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    } BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) String word = input.readLine(); word input.readLine() input.readLine input int start = -1 start -1 1 end = -1; end -1 1 for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < word.length() i word.length() word.length word i++ i++ i {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        } {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        } if (word.charAt(i) == 'A'){
                start = i;
                break;
            } word.charAt(i) == 'A' word.charAt(i) word.charAt word i 'A' {
                start = i;
                break;
            } start = i start i break; for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        } int i = word.length() - 1; int i = word.length() - 1; i word.length() - 1 word.length() word.length word 1 i > 0 i 0 i-- i-- i {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        } {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        } if (word.charAt(i) == 'Z'){
                end = i;
                break;
            } word.charAt(i) == 'Z' word.charAt(i) word.charAt word i 'Z' {
                end = i;
                break;
            } end = i end i break; System.out.println(end - start + 1) System.out.println System.out System System.out end - start + 1 end - start end start 1 String[] args args public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    }
} public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int start = -1, end = -1;
        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'A'){
                start = i;
                break;
            }
        }

        for (int i = word.length() - 1; i > 0; i--) {
            if (word.charAt(i) == 'Z'){
                end = i;
                break;
            }
        }

        System.out.println(end - start + 1);
    }
}
