fun main(arr:Array<String>) {
    val s = readLine()!!
    var aIndex  = -1
    var zIndex = -1
    for(i in (0 until s.length)) {
        if(s[i] == 'A') {
            if(aIndex < 0) {
                aIndex = i
            }
        } else if(s[i] == 'Z') {
            zIndex = i
        }
    }
    println(zIndex - aIndex + 1)
}