import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    } main {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.next(); input sc.next() sc.next sc int first = -1 first -1 1 last = -2; last -2 2 for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < input.length() i input.length() input.length input i++ i++ i {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        } {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        } if(input.charAt(i) == 'A'){
                first = i;
                break;
            } input.charAt(i) == 'A' input.charAt(i) input.charAt input i 'A' {
                first = i;
                break;
            } first = i first i break; for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        } int i = input.length() - 1; int i = input.length() - 1; i input.length() - 1 input.length() input.length input 1 i >= 0 i 0 i-- i-- i {
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        } {
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        } if(input.charAt(i) == 'Z'){
                last = i;
                break;
            } input.charAt(i) == 'Z' input.charAt(i) input.charAt input i 'Z' {
                last = i;
                break;
            } last = i last i break; System.out.println(last - first + 1) System.out.println System.out System System.out last - first + 1 last - first last first 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    }
}