import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    } main {
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] array = s.toCharArray(); array s.toCharArray() s.toCharArray s int first = 0; first 0 int end = s.length(); end s.length() s.length s for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      } int i = 0; int i = 0; i 0 i < end i end i++ i++ i {
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      } {
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      } if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        } s.substring(i,i+1).equals("A") s.substring(i,i+1).equals s.substring(i,i+1) s.substring s i i+1 i 1 "A" {
          first = i+1;
          break;
        } first = i+1 first i+1 i 1 break; for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      } int i = end; int i = end; i end i > 0 i 0 i-- i-- i {
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      } {
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      } if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        } s.substring(i-1,i).equals("Z") s.substring(i-1,i).equals s.substring(i-1,i) s.substring s i-1 i 1 i "Z" {
        	end = i;
          break;
        } end = i end i break; System.out.println(end-first+1) System.out.println System.out System System.out end-first+1 end-first end first 1 String[] args args public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] array = s.toCharArray();
      int first = 0;
      int end = s.length();
      for(int i = 0;i < end;i++){
      	if(s.substring(i,i+1).equals("A")){
          first = i+1;
          break;
        }
      }
      for(int i = end;i > 0;i--){
      	if(s.substring(i-1,i).equals("Z")){
        	end = i;
          break;
        }
      }
      System.out.println(end-first+1);
    }
}
