import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	}
} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	} main {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s=sc.nextLine(); s sc.nextLine() sc.nextLine sc int[] x=new int[s.length()]; x new int[s.length()] s.length() s.length s int sum = 0; sum 0 int a = 0 a 0 b = 0; b 0 for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		} 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'){
				a = i;
				break;
			}
		} {
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		} if(s.charAt(i)=='A'){
				a = i;
				break;
			} s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
				a = i;
				break;
			} a = i a i break; for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		} int i=s.length()-1; int i=s.length()-1; i s.length()-1 s.length() s.length s 1 i>=0 i 0 i-- i-- i {
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		} {
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		} if(s.charAt(i)=='Z'){
				b = i;
				break;
			} s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
				b = i;
				break;
			} b = i b i break; sum = Math.abs(b-a+1) sum Math.abs(b-a+1) Math.abs Math b-a+1 b-a b a 1 System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	}
}