import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 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().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 1);
	} main {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = sc.next().split(""); s sc.next().split("") sc.next().split sc.next() sc.next sc "" int indexA = 0; indexA 0 int indexZ = 0; indexZ 0 boolean top = true; top true for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		} 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") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		} {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		} if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			} s[i].equals("A") && top s[i].equals("A") s[i].equals s[i] s i "A" top {
				indexA = i;
				top = false;
			} indexA = i indexA i top = false top false if (s[i].equals("Z"))
				indexZ = i; s[i].equals("Z") s[i].equals s[i] s i "Z" indexZ = i indexZ i System.out.println(indexZ - indexA + 1) System.out.println System.out System System.out indexZ - indexA + 1 indexZ - indexA indexZ indexA 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 1);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 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().split("");
		int indexA = 0;
		int indexZ = 0;
		boolean top = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A") && top) {
				indexA = i;
				top = false;
			}
			if (s[i].equals("Z"))
				indexZ = i;
		}
		System.out.println(indexZ - indexA + 1);
	}
}