import java.util.Scanner;

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

		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String str = sc.next();
		int s = 0, e = 0, ans = 0;
		
		for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		}
		
		for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		}
		
		ans = e - s;
		
		
		System.out.println(ans);

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String str = sc.next();
		int s = 0, e = 0, ans = 0;
		
		for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		}
		
		for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		}
		
		ans = e - s;
		
		
		System.out.println(ans);

		sc.close();
	} main {
		Scanner sc = new Scanner((System.in));
		String str = sc.next();
		int s = 0, e = 0, ans = 0;
		
		for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		}
		
		for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		}
		
		ans = e - s;
		
		
		System.out.println(ans);

		sc.close();
	} Scanner sc = new Scanner((System.in)); sc new Scanner((System.in)) String str = sc.next(); str sc.next() sc.next sc int s = 0 s 0 e = 0 e 0 ans = 0; ans 0 for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		} {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		} if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			} str.substring(i, i + 1).equals("A") str.substring(i, i + 1).equals str.substring(i, i + 1) str.substring str i i + 1 i 1 "A" {
				s = i;
				break;
			} s = i s i break; for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		} int i = str.length(); int i = str.length(); i str.length() str.length str i > 0 i 0 i-- i-- i {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		} {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		} if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			} str.substring(i - 1, i).equals("Z") str.substring(i - 1, i).equals str.substring(i - 1, i) str.substring str i - 1 i 1 i "Z" {
				e = i;
				break;
			} e = i e i break; ans = e - s ans e - s e s System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String str = sc.next();
		int s = 0, e = 0, ans = 0;
		
		for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		}
		
		for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		}
		
		ans = e - s;
		
		
		System.out.println(ans);

		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String str = sc.next();
		int s = 0, e = 0, ans = 0;
		
		for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		}
		
		for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		}
		
		ans = e - s;
		
		
		System.out.println(ans);

		sc.close();
	}
} Main
import java.util.Scanner;

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

		sc.close();
	}
}
