import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	String s = scan.next() ;
    String s2 = s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1);
    
    
    System.out.println(s2.length());
  }
} import java.util.* ; util.* java import java.math.*; math.* java class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	String s = scan.next() ;
    String s2 = s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1);
    
    
    System.out.println(s2.length());
  }
} Main public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	String s = scan.next() ;
    String s2 = s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1);
    
    
    System.out.println(s2.length());
  } main {
    Scanner scan = new Scanner (System.in);
	String s = scan.next() ;
    String s2 = s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1);
    
    
    System.out.println(s2.length());
  } Scanner scan = new Scanner (System.in); scan new Scanner (System.in) String s = scan.next() ; s scan.next() scan.next scan String s2 = s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1); s2 s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1) s.substring s s.indexOf('A') s.indexOf s 'A' s.lastIndexOf('Z')+1 s.lastIndexOf('Z') s.lastIndexOf s 'Z' 1 System.out.println(s2.length()) System.out.println System.out System System.out s2.length() s2.length s2 String[] args args
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	String s = scan.next() ;
    String s2 = s.substring(s.indexOf('A') , s.lastIndexOf('Z')+1);
    
    
    System.out.println(s2.length());
  }
}
