import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    }
} import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    }
} Main /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    } main {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    } try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        } {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String array[] = s.split(""); array s.split("") s.split s "" int a = -1; a -1 1 int z = 0; z 0 for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            } int i = 0; int i = 0; i 0 i < array.length i array.length array array.length i++ i++ i {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            } {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            } if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                } a < 0 a 0 {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } if (array[i].equals("A")) {
                        a = i;
                    } array[i].equals("A") array[i].equals array[i] array i "A" {
                        a = i;
                    } a = i a i {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                } if (array[i].equals("Z")) {
                        z = i;
                    } array[i].equals("Z") array[i].equals array[i] array i "Z" {
                        z = i;
                    } z = i z i System.out.println(z - a + 1) System.out.println System.out System System.out z - a + 1 z - a z a 1 String...args args public class Main {
    /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    }
} public class Main {
    /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    }
} Main
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    }
}