// package ABC046

object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  
  val s = inputs.head

  println(solve(s))

  private def solve(s: String): Int = {
    val seq = scala.collection.mutable.ArrayBuffer.empty[Int]
    val aSeq = scala.collection.mutable.ArrayBuffer.empty[Int]
    val zSeq = scala.collection.mutable.ArrayBuffer.empty[Int]

    (0 until s.size).foreach { i =>
      s(i) match {
        case 'A' => aSeq.append(i)
        case 'Z' => zSeq.append(i)
        case _   => ()
      }
    }

    (0 until aSeq.size).foreach { i =>
      val start = aSeq(i)
      val graterSeq = zSeq.filter(z => start < z)
      graterSeq.size match {
        case 0 => ()
        case _ => seq.append(graterSeq.max - start + 1)
      }
    }
    seq.max
  }
}