object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  val aPos = s.indexOf("A")
  val zPos = s.lastIndexOf("Z")
  val az = s.slice(aPos, zPos+1)
  println(az.length)
}