import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	}
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	} main {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] C = sc.next().toCharArray(); C sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc sc.close() sc.close sc int n = C.length; n C.length C C.length int st = 0; st 0 for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        } {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        } if (C[i] == 'A') {
                st = i;
                break;
            } C[i] == 'A' C[i] C i 'A' {
                st = i;
                break;
            } st = i st i break; int gl = 0; gl 0 for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        } int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 --i --i i {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        } {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        } if (C[i] == 'Z') {
                gl = i;
                break;
            } C[i] == 'Z' C[i] C i 'Z' {
                gl = i;
                break;
            } gl = i gl i break; System.out.println(gl - st + 1) System.out.println System.out System System.out gl - st + 1 gl - st gl st 1 String[] args args public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	}
} public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] C = sc.next().toCharArray();
        sc.close();

        int n = C.length;
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (C[i] == 'A') {
                st = i;
                break;
            }
        }
        int gl = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (C[i] == 'Z') {
                gl = i;
                break;
            }
        }

        System.out.println(gl - st + 1);
	}
}
