import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s: String = sc.next()
    var a: Int = 0
    var z: Int = 0
    for (i in 0 until s.length) {
        if (s[i] == 'A') {
            a = i
            break
        }
    }
    for (i in s.length - 1 downTo 0) {
        if (s[i] == 'Z') {
            z = i
            break
        }
    }
    print(z - a + 1)
}