import java.util.*;

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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] array = sc.next().split("");
    int start =0;
    int first_A=0;
    int end =0;
    for(int i=0; i<array.length; i++){
    	if(array[i].equals("A") && first_A==0){
        	start=i;
            first_A=1;
        }
        if(array[i].equals("Z") && first_A !=0 ){
        	end =i;
        }
    }
    System.out.println(end - start + 1);
  }
}