import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                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[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                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[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                z = i;
            }
		}
		
		System.out.println(z-a+1);
	} main {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                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[] chara = str.toCharArray(); chara str.toCharArray() str.toCharArray str int a = 0; a 0 int z = 0; z 0 int ans = 0; ans 0 for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		} int i=str.length()-1; int i=str.length()-1; i str.length()-1 str.length() str.length str 1 i>=0 i 0 i-- i-- i {
		    if(chara[i]=='A'){
		        a = i;
		    }
		} {
		    if(chara[i]=='A'){
		        a = i;
		    }
		} if(chara[i]=='A'){
		        a = i;
		    } chara[i]=='A' chara[i] chara i 'A' {
		        a = i;
		    } a = i a i for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                z = i;
            }
		} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
            if(chara[i]=='Z'){
                z = i;
            }
		} {
            if(chara[i]=='Z'){
                z = i;
            }
		} if(chara[i]=='Z'){
                z = i;
            } chara[i]=='Z' chara[i] chara i 'Z' {
                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[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                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[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                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[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                z = i;
            }
		}
		
		System.out.println(z-a+1);
	}
}
