import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	}} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	}} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	} main {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s=sc.nextLine(); s sc.nextLine() sc.nextLine sc char c[]=s.toCharArray(); c s.toCharArray() s.toCharArray s int a=0; a 0 int b=0; b 0 for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
		if(c[i]=='A'){
			a=i;
			break;
		}
	} {
		if(c[i]=='A'){
			a=i;
			break;
		}
	} if(c[i]=='A'){
			a=i;
			break;
		} c[i]=='A' c[i] c i 'A' {
			a=i;
			break;
		} a=i a i break; for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	} int i=s.length()-1; int i=s.length()-1; i s.length()-1 s.length() s.length s 1 i>0 i 0 i-- i-- i {
		if(c[i]=='Z'){
			b=i;
			break;
		}
	} {
		if(c[i]=='Z'){
			b=i;
			break;
		}
	} if(c[i]=='Z'){
			b=i;
			break;
		} c[i]=='Z' c[i] c i 'Z' {
			b=i;
			break;
		} b=i b i break; System.out.println(b-a+1) System.out.println System.out System System.out b-a+1 b-a b a 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	}} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	}} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	}}