
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char A[] = new char[200000]; A new char[200000] 200000 A = sc.next().toCharArray() A sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int max=1; max 1 int count=0; count 0 boolean flag=false; flag false for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		} int i=0; int i=0; i 0 i<A.length i A.length A A.length i++ i++ i {
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		} {
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		} if(A[i]=='A'){
				flag=true;
			} A[i]=='A' A[i] A i 'A' {
				flag=true;
			} flag=true flag true if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			} A[i]=='Z' && flag A[i]=='Z' A[i] A i 'Z' flag {
				count++;
				if(max<count)
				max=count;
			} count++ count if(max<count)
				max=count; max<count max count max=count max count if(flag){
				count++;
			} flag {
				count++;
			} count++ count if(max<=1){System.out.println("0");}
		else{System.out.println(max);} max<=1 max 1 {System.out.println("0");} System.out.println("0") System.out.println System.out System System.out "0" {System.out.println(max);} System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	}
} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	}
}
