import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +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 indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +1);
	}

} Main public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +1);
	} main {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int indexStart = s.indexOf("A"); indexStart s.indexOf("A") s.indexOf s "A" int indexEnd = 0; indexEnd 0 String[] sArray = s.split(""); sArray s.split("") s.split s "" for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = 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(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		} {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		} if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			} sArray[i].equals("Z") sArray[i].equals sArray[i] sArray i "Z" {
				indexEnd = i;
				break;
			} indexEnd = i indexEnd i break; System.out.println(indexEnd - indexStart +1) System.out.println System.out System System.out indexEnd - indexStart +1 indexEnd - indexStart indexEnd indexStart 1 String[] args args public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +1);
	}

} public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +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 indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +1);
	}

}