import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	}
} import java.util.Scanner; Scanner java.util public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	}
} Main @SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	} main {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String str = scanner.next(); str scanner.next() scanner.next scanner String[] s = str.split(""); s str.split("") str.split str "" int max = 0; max 0 int count = 0; count 0 for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		} int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		} {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		} if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			} s[i].equals("A") s[i].equals s[i] s i "A" {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			} for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				} int j = i; int j = i; j i j < s.length j s.length s s.length j++ j++ j {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				} {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				} count++ count if (s[j].equals("Z")) {
						max = Math.max(max, count);
					} s[j].equals("Z") s[j].equals s[j] s j "Z" {
						max = Math.max(max, count);
					} max = Math.max(max, count) max Math.max(max, count) Math.max Math max count break; System.out.println(max) System.out.println System.out System System.out max String args[] args public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	}
} public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	}
} Main
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	}
}
