import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    } main {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int i = 0; i 0 int count = 0; count 0 int start = 0; start 0 int finish = 0; finish 0 String[] List = S.split(""); List S.split("") S.split S "" for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        } i = 0; i = 0 i 0 i < List.length i List.length List List.length i++ i++ i {
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        } {
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        } if(List[i].equals("A")){
             start = 1;
          } List[i].equals("A") List[i].equals List[i] List i "A" {
             start = 1;
          } start = 1 start 1 if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          } start == 1 start 1 {
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          } count += 1 count 1 if(List[i].equals("Z")){
              finish = count;
            } List[i].equals("Z") List[i].equals List[i] List i "Z" {
              finish = count;
            } finish = count finish count System.out.println(finish) System.out.println System.out System System.out finish String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    }
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    }
}