import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	} main {
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String b=scan.next(); b scan.next() scan.next scan int ans=0; ans 0 int count=0; count 0 for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			} int i=0; int i=0; i 0 i!=b.length() i b.length() b.length b i++ i++ i {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			} {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			} if(b.charAt(i)=='A') {
				ans=i;
				break;
			} b.charAt(i)=='A' b.charAt(i) b.charAt b i 'A' {
				ans=i;
				break;
			} ans=i ans i break; for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		} int i=b.length()-1; int i=b.length()-1; i b.length()-1 b.length() b.length b 1 i!=0 i 0 i-- i-- i {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		} {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		} if(b.charAt(i)=='Z') {
				count=i;
				break;
			} b.charAt(i)=='Z' b.charAt(i) b.charAt b i 'Z' {
				count=i;
				break;
			} count=i count i break; System.out.println(count-ans+1) System.out.println System.out System System.out count-ans+1 count-ans count ans 1 String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	}
}