import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  } main {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int a = 0; a 0 int z = 0; z 0 boolean testA = false; testA false int count = 0; count 0 for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    } {
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    } if(str.charAt(i) == 'A'){
            a = i;
            break;
        } str.charAt(i) == 'A' str.charAt(i) str.charAt str i 'A' {
            a = i;
            break;
        } a = i a i break; for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    } int i=str.length()-1; int i=str.length()-1; i str.length()-1 str.length() str.length str 1 i>0 i 0 i-- i-- i {
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    } {
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    } if(str.charAt(i) == 'Z'){
            z = i;
            break;
        } str.charAt(i) == 'Z' str.charAt(i) str.charAt str i 'Z' {
            z = i;
            break;
        } z = i z i break; System.out.println(z-a+1) System.out.println System.out System System.out z-a+1 z-a z a 1 String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  }
}