import java.util.Scanner;

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

        String s = sc.next();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+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();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+1);
    } main {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int min = 0; min 0 int max = 0; max 0 for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        } {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        } if (min == 0 && s.charAt(i) == 'A')
                min = i+1; min == 0 && s.charAt(i) == 'A' min == 0 min 0 s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' min = i+1 min i+1 i 1 if (min > 0 && s.charAt(i) == 'Z')
                max = i+1; min > 0 && s.charAt(i) == 'Z' min > 0 min 0 s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' max = i+1 max i+1 i 1 int ans = max - min; ans max - min max min System.out.println(ans+1) System.out.println System.out System System.out ans+1 ans 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+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();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+1);
    }
}