import java.util.Scanner;

public class Main {

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

		String s = sc.next();
		int start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+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 start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+1);
	} main {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int start = 0; start 0 int end = 0; end 0 String [] lists = s.split(""); lists s.split("") s.split s "" for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		} {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		} if (lists[i].equals("A")) {
				start = i;
				break;
			} lists[i].equals("A") lists[i].equals lists[i] lists i "A" {
				start = i;
				break;
			} start = i start i break; for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				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 (lists[i].equals("Z")) {
				end = i;
				break;
			}
		} {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		} if (lists[i].equals("Z")) {
				end = i;
				break;
			} lists[i].equals("Z") lists[i].equals lists[i] lists i "Z" {
				end = i;
				break;
			} end = i end i break; System.out.println(Math.abs(end - start)+1) System.out.println System.out System System.out Math.abs(end - start)+1 Math.abs(end - start) Math.abs Math end - start end start 1 String[] args args public class Main {

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

		String s = sc.next();
		int start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+1);
	}
} public class Main {

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

		String s = sc.next();
		int start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+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 start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+1);
	}
}
