fun main(args: Array<String>) {
    val s = readLine() ?: return
    val firstAPos = s.withIndex().first { it.value == 'A' }.index
    val lastZPos = s.withIndex().last { it.value == 'Z' }.index
    println(lastZPos - firstAPos + 1)
}