import java.util.Scanner;

public class Main {

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

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	}

} 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();
		sc.close();

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	}

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

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

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

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc sc.close() sc.close sc String[] sarr = s.split(""); sarr s.split("") s.split s "" boolean isReached = false; isReached false int posA = 0; posA 0 int posZ = 0; posZ 0 for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		} int i = 0; int i = 0; i 0 i < sarr.length i sarr.length sarr sarr.length i++ i++ i {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		} {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		} if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			} !isReached isReached {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			} if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				} sarr[i].equals("A") sarr[i].equals sarr[i] sarr i "A" {
					posA = i - 1;
					isReached = true;
				} posA = i - 1 posA i - 1 i 1 isReached = true isReached true continue; if(sarr[i].equals("Z")) {
				posZ = i;
			} sarr[i].equals("Z") sarr[i].equals sarr[i] sarr i "Z" {
				posZ = i;
			} posZ = i posZ i System.out.println(posZ - posA) System.out.println System.out System System.out posZ - posA posZ posA String[] args args public class Main {

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

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	}

} public class Main {

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

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	}

} Main
import java.util.Scanner;

public class Main {

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

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	}

}
