object Main {

  val scanner = new java.util.Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val target = scanner.next()
    val a = target.indexOf('A')
    val b = target.lastIndexOf('Z')
    print(b - a + 1)
  }

}
