import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  char[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - 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[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - first + 1);
}} Main public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  char[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - first + 1);
} main {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  char[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - first + 1);
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s int first; first int last; last for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  } int i = 0; int i = 0; i 0 i++ i++ i {
    if(c[i] == 'A'){
      first = i;
      break;
    }
  } {
    if(c[i] == 'A'){
      first = i;
      break;
    }
  } if(c[i] == 'A'){
      first = i;
      break;
    } c[i] == 'A' c[i] c i 'A' {
      first = i;
      break;
    } first = i first i break; for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  } int i = s.length()-1; int i = s.length()-1; i s.length()-1 s.length() s.length s 1 i-- i-- i {
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  } {
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  } if(c[i] == 'Z'){
      last = i;
      break;
    } c[i] == 'Z' c[i] c i 'Z' {
      last = i;
      break;
    } last = i last i break; System.out.println(last - first + 1) System.out.println System.out System System.out last - first + 1 last - first last 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[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - first + 1);
}} public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  char[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - 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[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - first + 1);
}}
