import java.io.*;
import java.util.*;

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc int result = 0; result 0 int start = 0; start 0 boolean startFlag = true; startFlag true int end = 0; end 0 for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		} 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' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		} {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		} if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			} s.charAt(i) == 'A' && startFlag s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' startFlag {
				start = i;
				startFlag = false;
			} start = i start i startFlag = false startFlag false if(s.charAt(i) == 'Z') {
				end = i;
			} s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
				end = i;
			} end = i end i result = s.substring(start, end+1).length() result s.substring(start, end+1).length() s.substring(start, end+1).length s.substring(start, end+1) s.substring s start end+1 end 1 System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc String[] args args public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	}
} public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	}
} Main
import java.io.*;
import java.util.*;

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int result = 0;
		int start = 0;
		boolean startFlag = true;
		int end = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A' && startFlag) {
				start = i;
				startFlag = false;
			} else if(s.charAt(i) == 'Z') {
				end = i;
			}
		}
		result = s.substring(start, end+1).length();
		System.out.println(result);

		sc.close();
	}
}