import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    }

} Main public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    } main {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    } @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int l = 0; l 0 int r = 0; r 0 for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        } int i = 0 ; int i = 0 ; i 0 i < s.length i s.length s s.length i++ i++ i {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        } {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        } if (s[i] == 'A') {
                l = i;
                break;
            } s[i] == 'A' s[i] s i 'A' {
                l = i;
                break;
            } l = i l i break; for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        } int i = s.length - 1 ; int i = s.length - 1 ; i s.length - 1 s.length s s.length 1 i >= 0 i 0 i-- i-- i {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        } {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        } if (s[i] == 'Z') {
                r = i;
                break;
            } s[i] == 'Z' s[i] s i 'Z' {
                r = i;
                break;
            } r = i r i break; System.out.print(r - l + 1) System.out.print System.out System System.out r - l + 1 r - l r l 1 String[] args args public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    }

} public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    }

}