import java.util.Scanner;

public class Main{
	public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
 		String s = sc.next();
 		char[] arr = s.toCharArray();
 		int count =0;
 		int idxA =0;
 		int idxZ =0;

 		for(int i=0; i<arr.length; i++){
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		}
 		for(int j = s.length()-1; j>=0; j--){
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 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[] arr = s.toCharArray();
 		int count =0;
 		int idxA =0;
 		int idxZ =0;

 		for(int i=0; i<arr.length; i++){
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		}
 		for(int j = s.length()-1; j>=0; j--){
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} Main public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
 		String s = sc.next();
 		char[] arr = s.toCharArray();
 		int count =0;
 		int idxA =0;
 		int idxZ =0;

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

 		for(int i=0; i<arr.length; i++){
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		}
 		for(int j = s.length()-1; j>=0; j--){
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] arr = s.toCharArray(); arr s.toCharArray() s.toCharArray s int count =0; count 0 int idxA =0; idxA 0 int idxZ =0; idxZ 0 for(int i=0; i<arr.length; i++){
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		} {
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		} if(arr[i] =='A'){
 				idxA = i;
 				break;
 			} arr[i] =='A' arr[i] arr i 'A' {
 				idxA = i;
 				break;
 			} idxA = i idxA i break; for(int j = s.length()-1; j>=0; j--){
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		} int j = s.length()-1; int j = s.length()-1; j s.length()-1 s.length() s.length s 1 j>=0 j 0 j-- j-- j {
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		} {
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		} if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			} arr[j] =='Z' arr[j] arr j 'Z' {
 				idxZ = j;
 				break;
 			} idxZ = j idxZ j break; System.out.println(idxZ - idxA + 1) System.out.println System.out System System.out idxZ - idxA + 1 idxZ - idxA idxZ idxA 1 String[] args args public class Main{
	public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
 		String s = sc.next();
 		char[] arr = s.toCharArray();
 		int count =0;
 		int idxA =0;
 		int idxZ =0;

 		for(int i=0; i<arr.length; i++){
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		}
 		for(int j = s.length()-1; j>=0; j--){
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} public class Main{
	public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
 		String s = sc.next();
 		char[] arr = s.toCharArray();
 		int count =0;
 		int idxA =0;
 		int idxZ =0;

 		for(int i=0; i<arr.length; i++){
 			if(arr[i] =='A'){
 				idxA = i;
 				break;
 			}
 		}
 		for(int j = s.length()-1; j>=0; j--){
 			if(arr[j] =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 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[] arr = s.toCharArray();
 		int count =0;
 		int idxA =0;
 		int idxZ =0;

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