import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.nextLine().toCharArray(); s sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc boolean isFound = false; isFound false int aLocation = 0; aLocation 0 int zLocation = 0; zLocation 0 for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        } int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        } {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        } if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            } s[i] == 'A' && !isFound s[i] == 'A' s[i] s i 'A' !isFound isFound {
                isFound = true;
                aLocation = i;
            } isFound = true isFound true aLocation = i aLocation i if(s[i] == 'Z') {
                zLocation = i;
            } s[i] == 'Z' s[i] s i 'Z' {
                zLocation = i;
            } zLocation = i zLocation i System.out.println(zLocation - aLocation + 1) System.out.println System.out System System.out zLocation - aLocation + 1 zLocation - aLocation zLocation aLocation 1 sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    }
}
