import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ss = next()

    var first = -1
    var last = -1

    ss.forEachIndexed() { index,  s ->
        if (first == -1 && s == 'A') first = index
        if (s == 'Z') last = index
    }

    println(last - first + 1)
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}