import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException{
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
}  import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{
	public static void main(String[] args) throws IOException{
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} Main public static void main(String[] args) throws IOException{
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	} main {
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	} BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in)); br new BufferedReader(
 			new InputStreamReader(System.in)) String s = br.readLine(); s br.readLine() br.readLine br int idxA =0; idxA 0 for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = 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'){
 				idxA = i;
 				break;
 			}
 		} {
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		} if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			} s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
 				idxA = i;
 				break;
 			} idxA = i idxA i break; int idxZ = s.length()-1; idxZ s.length()-1 s.length() s.length s 1 for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(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(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		} {
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		} if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			} s.charAt(j) =='Z' s.charAt(j) s.charAt s 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) throws IOException{
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} public class Main{
	public static void main(String[] args) throws IOException{
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException{
 		BufferedReader br = new BufferedReader(
 			new InputStreamReader(System.in));
 		String s = br.readLine();
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} 