import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 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.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 1));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 1));
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 1));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc sc.close() sc.close sc int idxA = 0; idxA 0 for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s ++i ++i i {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		} {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		} if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			} s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
				idxA = i;
				break;
			} idxA = i idxA i break; int idxZ = s.length()-1; idxZ s.length()-1 s.length() s.length s 1 for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = 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(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		} {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		} if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			} s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
				idxZ = i;
				break;
			} idxZ = i idxZ i break; System.out.println((idxZ - idxA + 1)) System.out.println System.out System System.out (idxZ - idxA + 1) idxZ - idxA idxZ idxA 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 1));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 1));
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		int idxA = 0;
		for(int i = 0;i < s.length();++i) {
			if(s.charAt(i) == 'A') {
				idxA = i;
				break;
			}
		}
		
		int idxZ = s.length()-1;
		for(int i = s.length()-1;i >= 0;--i) {
			if(s.charAt(i) == 'Z') {
				idxZ = i;
				break;
			}
		}
		
		System.out.println((idxZ - idxA + 1));
	}
}
