#!/bin/bash

read s

arr=($(echo $s | fold -b -w 1))

for ((i = 0; i < ${#arr[@]}; i++))
do
  if [ "${arr[$i]}" == "A" ]; then
    f=$i
    break    
  fi
done

for ((j = ${#arr[@]} - 1; j >= 0; j--))
do
  if [ "${arr[$j]}" == "Z" ]; then
    e=$j
    break
  fi    
done

echo $(($e - $f + 1))