import java.util.*;

public class Main
{
    public static void main(String... args){
        Scanner sc= new Scanner(System.in);
        String s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    }

} import java.util.*; util.* java public class Main
{
    public static void main(String... args){
        Scanner sc= new Scanner(System.in);
        String s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    }

} Main public static void main(String... args){
        Scanner sc= new Scanner(System.in);
        String s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    } main {
        Scanner sc= new Scanner(System.in);
        String s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    } Scanner sc= new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int first = -1; first -1 1 int last = -1; last -1 1 for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        } {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        } int c = s.charAt(i); c s.charAt(i) s.charAt s i if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            } c == 'A' && first == -1 c == 'A' c 'A' first == -1 first -1 1 {
                first = i;
            } first = i first i if (c == 'Z'){
                last = i;
            } c == 'Z' c 'Z' {
                last = i;
            } last = i last i 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 s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    }

} public class Main
{
    public static void main(String... args){
        Scanner sc= new Scanner(System.in);
        String s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    }

} Main
import java.util.*;

public class Main
{
    public static void main(String... args){
        Scanner sc= new Scanner(System.in);
        String s = sc.next();
        int first = -1;
        int last = -1;
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            if (c == 'A' && first == -1){
                first = i;
            } else if (c == 'Z'){
                last = i;
            }
        }
        System.out.println(last - first + 1);
    }

}