import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    } main {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc int count=s.lastIndexOf("Z")-s.indexOf("A")+1; count s.lastIndexOf("Z")-s.indexOf("A")+1 s.lastIndexOf("Z")-s.indexOf("A") s.lastIndexOf("Z") s.lastIndexOf s "Z" s.indexOf("A") s.indexOf s "A" 1 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc=new Scanner(System.in);
       
       String s=sc.next();
       
       int count=s.lastIndexOf("Z")-s.indexOf("A")+1;
       System.out.println(count);
    }
}
