import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] s = sc.next().split("");

        int a_pos=0;
        for(int i=0; i<s.length; i++){
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        }
        
        int z_pos=0;
        for(int i=s.length-1; i>=0; i--){
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        }

        int ans = z_pos - a_pos;
        
        System.out.println(ans+1);
        
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] s = sc.next().split("");

        int a_pos=0;
        for(int i=0; i<s.length; i++){
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        }
        
        int z_pos=0;
        for(int i=s.length-1; i>=0; i--){
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        }

        int ans = z_pos - a_pos;
        
        System.out.println(ans+1);
        
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] s = sc.next().split("");

        int a_pos=0;
        for(int i=0; i<s.length; i++){
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        }
        
        int z_pos=0;
        for(int i=s.length-1; i>=0; i--){
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        }

        int ans = z_pos - a_pos;
        
        System.out.println(ans+1);
        
    } main {
        Scanner sc = new Scanner(System.in);
        
        String[] s = sc.next().split("");

        int a_pos=0;
        for(int i=0; i<s.length; i++){
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        }
        
        int z_pos=0;
        for(int i=s.length-1; i>=0; i--){
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        }

        int ans = z_pos - a_pos;
        
        System.out.println(ans+1);
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = sc.next().split(""); s sc.next().split("") sc.next().split sc.next() sc.next sc "" int a_pos=0; a_pos 0 for(int i=0; i<s.length; i++){
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        } int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i {
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        } {
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        } if(s[i].equals("A")){
                a_pos = i;
                break;
            } s[i].equals("A") s[i].equals s[i] s i "A" {
                a_pos = i;
                break;
            } a_pos = i a_pos i break; int z_pos=0; z_pos 0 for(int i=s.length-1; i>=0; i--){
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        } int i=s.length-1; int i=s.length-1; i s.length-1 s.length s s.length 1 i>=0 i 0 i-- i-- i {
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        } {
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        } if(s[i].equals("Z")){
                z_pos = i;
                break;
            } s[i].equals("Z") s[i].equals s[i] s i "Z" {
                z_pos = i;
                break;
            } z_pos = i z_pos i break; int ans = z_pos - a_pos; ans z_pos - a_pos z_pos a_pos System.out.println(ans+1) System.out.println System.out System System.out ans+1 ans 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().split("");

        int a_pos=0;
        for(int i=0; i<s.length; i++){
            if(s[i].equals("A")){
                a_pos = i;
                break;
            }
        }
        
        int z_pos=0;
        for(int i=s.length-1; i>=0; i--){
            if(s[i].equals("Z")){
                z_pos = i;
                break;
            }
        }

        int ans = z_pos - a_pos;
        
        System.out.println(ans+1);
        
    }
}