import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	}
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	}
} Main public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	} main {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String s  = in.next(); s in.next() in.next in int nam = s.length(); nam s.length() s.length s int cnt = 0; cnt 0 int memo = 0; memo 0 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 } int i = 0; int i = 0; i 0 i < nam i nam i++ i++ i {
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 } {
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 } if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     } s.charAt(i)=='A' && cnt == 0 s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' cnt == 0 cnt 0 {
		         cnt = 1;
		     } cnt = 1 cnt 1 if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     } cnt>0 cnt 0 {
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     } cnt++ cnt if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
		             memo = cnt;
		         } memo = cnt memo cnt System.out.print(memo) System.out.print System.out System System.out memo String[] args args public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	}
} public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	}
} Main
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	}
}