import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 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 length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 1);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 1);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int length = s.length(); length s.length() s.length s int count_A = -1; count_A -1 1 int count_Z = 0; count_Z 0 for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        } int i = 0; int i = 0; i 0 i < length i length i++ i++ i {
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        } {
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        } char moji = s.charAt(i); moji s.charAt(i) s.charAt s i if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            } moji == 'A' moji 'A' {
                if(count_A == -1){
                    count_A = i;
                }
            } if(count_A == -1){
                    count_A = i;
                } count_A == -1 count_A -1 1 {
                    count_A = i;
                } count_A = i count_A i if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            } moji == 'Z' moji 'Z' {
                if(count_Z < i){
                    count_Z = i;
                }
            } if(count_Z < i){
                    count_Z = i;
                } count_Z < i count_Z i {
                    count_Z = i;
                } count_Z = i count_Z i System.out.println(count_Z - count_A + 1) System.out.println System.out System System.out count_Z - count_A + 1 count_Z - count_A count_Z count_A 1 String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 1);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 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 length = s.length();
        int count_A = -1;
        int count_Z = 0;

        for(int i = 0; i < length; i++){
            char moji = s.charAt(i);
            if(moji == 'A'){
                if(count_A == -1){
                    count_A = i;
                }
            }else if(moji == 'Z'){
                if(count_Z < i){
                    count_Z = i;
                }
            }
        }
        System.out.println(count_Z - count_A + 1);
    }
}