import java.util.Scanner;

public class Main {

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

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

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int s_length = s.length(); 
		int i = 0;
		int j = 0;
		for(i = 0; i < s_length; i++) {
			if(s.charAt(i) == 'A') {
				break;
			}
		}
		for(j = s_length - 1; j >= 0; j--) {
			if(s.charAt(j) == 'Z') {
				break;
			}
		}
		String str = s.substring(i, j + 1);
		System.out.println(str.length());
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int s_length = s.length(); 
		int i = 0;
		int j = 0;
		for(i = 0; i < s_length; i++) {
			if(s.charAt(i) == 'A') {
				break;
			}
		}
		for(j = s_length - 1; j >= 0; j--) {
			if(s.charAt(j) == 'Z') {
				break;
			}
		}
		String str = s.substring(i, j + 1);
		System.out.println(str.length());
	}
}