import java.util.Scanner;

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

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 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.next();

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 1);

	}

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

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 1);

	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 1);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int min = s.length(); min s.length() s.length s int max = 0; max 0 for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		} {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		} if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			} 'A'==s.charAt(i) 'A' s.charAt(i) s.charAt s i {
				min = Math.min(min, i);
			} min = Math.min(min, i) min Math.min(min, i) Math.min Math min i if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			} 'Z'==s.charAt(i) 'Z' s.charAt(i) s.charAt s i {
				max = Math.max(max, i);
			} max = Math.max(max, i) max Math.max(max, i) Math.max Math max i System.out.println((max - min) + 1) System.out.println System.out System System.out (max - min) + 1 (max - min) max min 1 String[]args args public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 1);

	}

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

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 1);

	}

} Main
import java.util.Scanner;

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

		int min = s.length();
		int max = 0;

		for(int i = 0; i < s.length(); i++) {
			if('A'==s.charAt(i)) {
				min = Math.min(min, i);
			}
			if('Z'==s.charAt(i)) {
				max = Math.max(max, i);
			}
		}
		System.out.println((max - min) + 1);

	}

}