import java.util.Scanner;

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

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cs = s.toCharArray();

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cs = s.toCharArray();

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cs = s.toCharArray();

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] cs = s.toCharArray(); cs s.toCharArray() s.toCharArray s int mini = 0; mini 0 for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < cs.length i cs.length cs cs.length i++ i++ i {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        } {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        } if (cs[i] == 'A') {
                mini = i;
                break;
            } cs[i] == 'A' cs[i] cs i 'A' {
                mini = i;
                break;
            } mini = i mini i break; int maxi = 0; maxi 0 for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        } int i = cs.length - 1; int i = cs.length - 1; i cs.length - 1 cs.length cs cs.length 1 i >= 0 i 0 i-- i-- i {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        } {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        } if (cs[i] == 'Z') {
                maxi = i;
                break;
            } cs[i] == 'Z' cs[i] cs i 'Z' {
                maxi = i;
                break;
            } maxi = i maxi i break; System.out.println(maxi - mini + 1) System.out.println System.out System System.out maxi - mini + 1 maxi - mini maxi mini 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cs = s.toCharArray();

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cs = s.toCharArray();

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    }
} Main
import java.util.Scanner;

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

        int mini = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'A') {
                mini = i;
                break;
            }
        }

        int maxi = 0;
        for (int i = cs.length - 1; i >= 0; i--) {
            if (cs[i] == 'Z') {
                maxi = i;
                break;
            }
        }
        System.out.println(maxi - mini + 1);
    }
}
