import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        //int N = s.length();
        String[] array = s.split("");
        
        int start = 0;
        int end = 0;
        String A = "A";
        String Z = "Z";
        for(int i = 0; i < s.length(); i++){
            String a = array[i];
            if(a.equals(A)){
                start = i;
                break;
            }
        }
        for(int i = start; i < s.length(); i++){
            String b = array[i];
            if(b.equals(Z)){
                end = i;
            }
        }

        System.out.println(end-start+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 N = s.length();
        String[] array = s.split("");
        
        int start = 0;
        int end = 0;
        String A = "A";
        String Z = "Z";
        for(int i = 0; i < s.length(); i++){
            String a = array[i];
            if(a.equals(A)){
                start = i;
                break;
            }
        }
        for(int i = start; i < s.length(); i++){
            String b = array[i];
            if(b.equals(Z)){
                end = i;
            }
        }

        System.out.println(end-start+1);
        
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        //int N = s.length();
        String[] array = s.split("");
        
        int start = 0;
        int end = 0;
        String A = "A";
        String Z = "Z";
        for(int i = 0; i < s.length(); i++){
            String a = array[i];
            if(a.equals(A)){
                start = i;
                break;
            }
        }
        for(int i = start; i < s.length(); i++){
            String b = array[i];
            if(b.equals(Z)){
                end = i;
            }
        }

        System.out.println(end-start+1);
        
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        //int N = s.length();
        String[] array = s.split("");
        
        int start = 0;
        int end = 0;
        String A = "A";
        String Z = "Z";
        for(int i = 0; i < s.length(); i++){
            String a = array[i];
            if(a.equals(A)){
                start = i;
                break;
            }
        }
        for(int i = start; i < s.length(); i++){
            String b = array[i];
            if(b.equals(Z)){
                end = i;
            }
        }

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

        System.out.println(end-start+1);
        
    }
}