import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	}
 
} import java.util.*; util.* java public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	}
 
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	} main {
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc char[] c = str.toCharArray(); c str.toCharArray() str.toCharArray str int A = str.length(); A str.length() str.length str int Z = 0; Z 0 for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		} {
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		} String s = String.valueOf(str.charAt(i)); s String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			} s.equals("A") s.equals s "A" {
				if(A>i){
					A=i;
				}
			} if(A>i){
					A=i;
				} A>i A i {
					A=i;
				} A=i A i if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			} s.equals("Z") s.equals s "Z" {
				if(Z<i){
					Z=i;
				}
			} if(Z<i){
					Z=i;
				} Z<i Z i {
					Z=i;
				} Z=i Z i System.out.println(Z-A+1) System.out.println System.out System System.out Z-A+1 Z-A Z A 1 String[] args args public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	}
 
} public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	}
 
} Main
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	}
 
}