import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pa = Integer.MAX_VALUE;
        int pz = -1;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        }
        System.out.println(pz-pa+1);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pa = Integer.MAX_VALUE;
        int pz = -1;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        }
        System.out.println(pz-pa+1);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pa = Integer.MAX_VALUE;
        int pz = -1;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        }
        System.out.println(pz-pa+1);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pa = Integer.MAX_VALUE;
        int pz = -1;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        }
        System.out.println(pz-pa+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int pa = Integer.MAX_VALUE; pa Integer.MAX_VALUE Integer Integer.MAX_VALUE int pz = -1; pz -1 1 for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        } {
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        } if(s.charAt(i)=='A') pa = Math.min(pa,i); s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' pa = Math.min(pa,i) pa Math.min(pa,i) Math.min Math pa i if(s.charAt(i)=='Z') pz = Math.max(pz,i); s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' pz = Math.max(pz,i) pz Math.max(pz,i) Math.max Math pz i System.out.println(pz-pa+1) System.out.println System.out System System.out pz-pa+1 pz-pa pz pa 1 String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pa = Integer.MAX_VALUE;
        int pz = -1;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        }
        System.out.println(pz-pa+1);
    }
}
