import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    } main {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String data = scanner.nextLine(); data scanner.nextLine() scanner.nextLine scanner int posA = 0; posA 0 int posZ = 0; posZ 0 boolean foundPosA = false; foundPosA false for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        } int i=0; int i=0; i 0 i<data.length() i data.length() data.length data i++ i++ i {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        } {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        } if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            } data.charAt(i) == 'A' && !foundPosA data.charAt(i) == 'A' data.charAt(i) data.charAt data i 'A' !foundPosA foundPosA {
                posA = i;
                foundPosA = true;
            } posA = i posA i foundPosA = true foundPosA true if(data.charAt(i) == 'Z'){
                posZ = i;
            } data.charAt(i) == 'Z' data.charAt(i) data.charAt data i 'Z' {
                posZ = i;
            } posZ = i posZ i String output = data.substring(posA,posZ+1); output data.substring(posA,posZ+1) data.substring data posA posZ+1 posZ 1 System.out.println(output.length()) System.out.println System.out System System.out output.length() output.length output String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    }
}
