import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	}
	public static int sample(int n) {
		return n;
	}

} 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 minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	}
	public static int sample(int n) {
		return n;
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	} main {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int minA = S.length(); minA S.length() S.length S int maxX = 0; maxX 0 for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = 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' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		} {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		} if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			} S.charAt(i)=='A' && i<=minA S.charAt(i)=='A' S.charAt(i) S.charAt S i 'A' i<=minA i minA {
				minA=i;
			} minA=i minA i if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			} S.charAt(i)=='Z' && i>=maxX S.charAt(i)=='Z' S.charAt(i) S.charAt S i 'Z' i>=maxX i maxX {
				maxX = i;
			} maxX = i maxX i System.out.println(maxX-minA+1) System.out.println System.out System System.out maxX-minA+1 maxX-minA maxX minA 1 String[] args args public static int sample(int n) {
		return n;
	} sample {
		return n;
	} return n; n int n n public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	}
	public static int sample(int n) {
		return n;
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	}
	public static int sample(int n) {
		return n;
	}

} 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 minA = S.length();
		int maxX = 0;

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A' && i<=minA) {
				minA=i;
			}else if(S.charAt(i)=='Z' && i>=maxX){
				maxX = i;
			}
		}
		System.out.println(maxX-minA+1);


	}
	public static int sample(int n) {
		return n;
	}

}
