import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  }
} Main public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  } main {
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) String U = s.next(); U s.next() s.next s int a = 0; a 0 int b = U.length() - 1; b U.length() - 1 U.length() U.length U 1 while (U.charAt(a) != 'A'){
      a++;
    } U.charAt(a) != 'A' U.charAt(a) U.charAt U a 'A' {
      a++;
    } a++ a while (U.charAt(b) != 'Z'){
      b--;
    } U.charAt(b) != 'Z' U.charAt(b) U.charAt U b 'Z' {
      b--;
    } b-- b System.out.println(b - a + 1) System.out.println System.out System System.out b - a + 1 b - a b a 1 String[] args args public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  }
} public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  }
} Main
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  }
}
