

import java.util.Scanner;

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

		int st=0;
		int gl=a.length()-1;


		for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		}

		for(int i=a.length()-1; i>=0; i--) {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		}
		System.out.println(gl-st+1);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();

		int st=0;
		int gl=a.length()-1;


		for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		}

		for(int i=a.length()-1; i>=0; i--) {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		}
		System.out.println(gl-st+1);
	}
} Main public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();

		int st=0;
		int gl=a.length()-1;


		for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		}

		for(int i=a.length()-1; i>=0; i--) {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		}
		System.out.println(gl-st+1);
	} main {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();

		int st=0;
		int gl=a.length()-1;


		for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		}

		for(int i=a.length()-1; i>=0; i--) {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		}
		System.out.println(gl-st+1);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String a=sc.next(); a sc.next() sc.next sc int st=0; st 0 int gl=a.length()-1; gl a.length()-1 a.length() a.length a 1 for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		} int i=0; int i=0; i 0 i<a.length() i a.length() a.length a i++ i++ i {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		} {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		} if(a.charAt(i)=='A') {
				st=i+1;
				break;
			} a.charAt(i)=='A' a.charAt(i) a.charAt a i 'A' {
				st=i+1;
				break;
			} st=i+1 st i+1 i 1 break; for(int i=a.length()-1; i>=0; i--) {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		} int i=a.length()-1; int i=a.length()-1; i a.length()-1 a.length() a.length a 1 i>=0 i 0 i-- i-- i {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		} {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		} if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			} a.charAt(i)=='Z' a.charAt(i) a.charAt a i 'Z' {
				gl=i+1;
				break;
			} gl=i+1 gl i+1 i 1 break; System.out.println(gl-st+1) System.out.println System.out System System.out gl-st+1 gl-st gl st 1 String[] ag ag


import java.util.Scanner;

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

		int st=0;
		int gl=a.length()-1;


		for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='A') {
				st=i+1;
				break;
			}
		}

		for(int i=a.length()-1; i>=0; i--) {
			if(a.charAt(i)=='Z') {
				gl=i+1;
				break;
			}
		}
		System.out.println(gl-st+1);
	}
}