import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    } main {
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String str =  scanner.next(); str scanner.next() scanner.next scanner int length_a = 0; length_a 0 int length_z = 0; length_z 0 int margin; margin String[] strArray = new String[str.length()]; strArray new String[str.length()] str.length() str.length str ArrayList<String> mojiArray = new ArrayList<String>(); mojiArray new ArrayList<String>() for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i ++ i ++ i {
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        } {
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        } char str2 = str.charAt(i); str2 str.charAt(i) str.charAt str i if(str2 == 'Z'){
                length_z = i;
            } str2 == 'Z' str2 'Z' {
                length_z = i;
            } length_z = i length_z i for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i ++ i ++ i {
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        } {
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        } char str3 = str.charAt(i); str3 str.charAt(i) str.charAt str i if(str3 == 'A') {
                length_a = i;
                break;
            } str3 == 'A' str3 'A' {
                length_a = i;
                break;
            } length_a = i length_a i break; margin = length_z - length_a + 1 margin length_z - length_a + 1 length_z - length_a length_z length_a 1 System.out.println(margin) System.out.println System.out System System.out margin String[] args args public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    }
} public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str =  scanner.next();
        int length_a = 0;
        int length_z = 0;
        int margin;

        String[] strArray = new String[str.length()];
        ArrayList<String> mojiArray = new ArrayList<String>();

        for(int i = 0; i < str.length(); i ++){
            char str2 = str.charAt(i);

            if(str2 == 'Z'){
                length_z = i;
            }
        }

        for(int i = 0; i < str.length(); i ++){
            char str3 = str.charAt(i);

            if(str3 == 'A') {
                length_a = i;
                break;
            }
        }
        margin = length_z - length_a + 1;
        System.out.println(margin);
    }
}
