import java.io.*;
import java.util.*;
public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  }
} Main public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  } main {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  } String line = null; line null BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) line = br.readLine() line br.readLine() br.readLine br char[] charArray = line.toCharArray(); charArray line.toCharArray() line.toCharArray line int firstA = 0; firstA 0 int lastZ = 0; lastZ 0 for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    } int i = 0; int i = 0; i 0 i < charArray.length i charArray.length charArray charArray.length i++ i++ i {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    } {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    } if (charArray[i] == 'A') {
        firstA = i;
        break;
      } charArray[i] == 'A' charArray[i] charArray i 'A' {
        firstA = i;
        break;
      } firstA = i firstA i break; for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    } int i = (charArray.length - 1); int i = (charArray.length - 1); i (charArray.length - 1) charArray.length charArray charArray.length 1 i > 0 i 0 i-- i-- i {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    } {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    } if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      } charArray[i] == 'Z' charArray[i] charArray i 'Z' {
        lastZ = i;
        break;
      } lastZ = i lastZ i break; System.out.println(lastZ - firstA + 1) System.out.println System.out System System.out lastZ - firstA + 1 lastZ - firstA lastZ firstA 1 String[] args args public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  }
} public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  }
} Main
import java.io.*;
import java.util.*;
public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    char[] charArray = line.toCharArray();
    int firstA = 0;
    int lastZ = 0;
    for (int i = 0; i < charArray.length; i++) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'A') {
        firstA = i;
        break;
      }
    }
    for (int i = (charArray.length - 1); i > 0 ; i--) {
      //System.out.println(charArray[i]);
      if (charArray[i] == 'Z') {
        lastZ = i;
        break;
      }
    }
    //System.out.println(firstA + "," + lastZ);
    System.out.println(lastZ - firstA + 1);
  }
}