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