import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int i = 0;
        int j = s.length() - 1;

        for (; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                break;
            }
        }
        for (; j >= i; j--) {
            if (s.charAt(j) == 'Z') {
                break;
            }
        }
        System.out.println(j - i + 1);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int i = 0;
        int j = s.length() - 1;

        for (; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                break;
            }
        }
        for (; j >= i; j--) {
            if (s.charAt(j) == 'Z') {
                break;
            }
        }
        System.out.println(j - i + 1);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int i = 0;
        int j = s.length() - 1;

        for (; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                break;
            }
        }
        for (; j >= i; j--) {
            if (s.charAt(j) == 'Z') {
                break;
            }
        }
        System.out.println(j - i + 1);
    } main {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int i = 0;
        int j = s.length() - 1;

        for (; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                break;
            }
        }
        for (; j >= i; j--) {
            if (s.charAt(j) == 'Z') {
                break;
            }
        }
        System.out.println(j - i + 1);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s = scanner.nextLine(); s scanner.nextLine() scanner.nextLine scanner int i = 0; i 0 int j = s.length() - 1; j s.length() - 1 s.length() s.length s 1 for (; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                break;
            }
        } ; i < s.length() i s.length() s.length s i++ i++ i {
            if (s.charAt(i) == 'A') {
                break;
            }
        } {
            if (s.charAt(i) == 'A') {
                break;
            }
        } if (s.charAt(i) == 'A') {
                break;
            } s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
                break;
            } break; for (; j >= i; j--) {
            if (s.charAt(j) == 'Z') {
                break;
            }
        } ; j >= i j i j-- j-- j {
            if (s.charAt(j) == 'Z') {
                break;
            }
        } {
            if (s.charAt(j) == 'Z') {
                break;
            }
        } if (s.charAt(j) == 'Z') {
                break;
            } s.charAt(j) == 'Z' s.charAt(j) s.charAt s j 'Z' {
                break;
            } break; System.out.println(j - i + 1) System.out.println System.out System System.out j - i + 1 j - i j i 1 String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int i = 0;
        int j = s.length() - 1;

        for (; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                break;
            }
        }
        for (; j >= i; j--) {
            if (s.charAt(j) == 'Z') {
                break;
            }
        }
        System.out.println(j - i + 1);
    }
}
