import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	}
} 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 a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int a =0; a 0 for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		} ; a<s.length() a s.length() s.length s a++ a++ a {
			if (s.charAt(a)=='A') {
				break;
			}
		} {
			if (s.charAt(a)=='A') {
				break;
			}
		} if (s.charAt(a)=='A') {
				break;
			} s.charAt(a)=='A' s.charAt(a) s.charAt s a 'A' {
				break;
			} break; for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		} int i=s.length()-1; int i=s.length()-1; i s.length()-1 s.length() s.length s 1 i>=0 i 0 i-- i-- i {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		} {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		} if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			} s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
				System.out.println(i-a+1);
				break;
			} System.out.println(i-a+1) System.out.println System.out System System.out i-a+1 i-a i a 1 break; String[] args args public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	}
} 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 a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	}
}