

fun main(array: Array<String>) {
    val s = readLine()!!
    var minA = s.length
    var maxZ = 0
    repeat(s.length) {
        if(s[it] == 'A') {
            val tempA = it
            if(tempA < minA) minA = tempA
        }
        if(s[it] == 'Z') {
            val tempZ = it
            if(maxZ < tempZ) maxZ = tempZ
        }
    }
    print(maxZ - minA + 1)
}