import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+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();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+1);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+1);
	} main {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc char[] ary = S.toCharArray(); ary S.toCharArray() S.toCharArray S int A = 0; A 0 int B = 0; B 0 for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < ary.length i ary.length ary ary.length i++ i++ i {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		} {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		} if(ary[i] == 'A') {
				A = i;
				break;
			} ary[i] == 'A' ary[i] ary i 'A' {
				A = i;
				break;
			} A = i A i break; for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		} int j = ary.length-1; int j = ary.length-1; j ary.length-1 ary.length ary ary.length 1 j > 0 j 0 j-- j-- j {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		} {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		} if(ary[j] == 'Z') {
				B = j;
				break;
			} ary[j] == 'Z' ary[j] ary j 'Z' {
				B = j;
				break;
			} B = j B j break; System.out.println(B-A+1) System.out.println System.out System System.out B-A+1 B-A B A 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+1);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+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();
		char[] ary = S.toCharArray();
		int A = 0;
		int B = 0;

		for(int i = 0; i < ary.length; i++) {
			if(ary[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int j = ary.length-1; j > 0; j--) {
			if(ary[j] == 'Z') {
				B = j;
				break;
			}
		}
		System.out.println(B-A+1);
	}

}
