import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    }
} import java.io.InputStream; InputStream java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) String s = in.next(); s in.next() in.next in int idex = -1; idex -1 1 int c = 0; c 0 int ans = 0; ans 0 for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        } {
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        } if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            } idex==-1 idex -1 1 {
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            } if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                } s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
                    idex = i;
                    c++;
                } idex = i idex i c++ c {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            } c++ c if (s.charAt(i)=='Z'){
                    ans=c;
                } s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
                    ans=c;
                } ans=c ans c System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    }
} Main
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    }
}