object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val iobuf = readLine.split(" ").head.dropWhile(_ != 'A').reverse.dropWhile(_ != 'Z').length
    println(iobuf)
  }
}
