fun main(args: Array<String>) {
	var s = readLine() ?: return

	var cnt = s.length
	cnt -= calc(s, 'A')

	s = s.reversed()
	cnt -= calc(s, 'Z')

	println(cnt)
}

fun calc(s: String, c: Char): Int {
	var cnt = 0
	var i = 0
	while (s[i] != c && cnt < s.length) {
		cnt++
		i++
	}
	return cnt
}
