import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ns = s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1);
		System.out.println(ns.length());
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ns = s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1);
		System.out.println(ns.length());
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ns = s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1);
		System.out.println(ns.length());
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ns = s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1);
		System.out.println(ns.length());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String ns = s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1); ns s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1) s.substring s s.indexOf("A") s.indexOf s "A" s.lastIndexOf("Z")+1 s.lastIndexOf("Z") s.lastIndexOf s "Z" 1 System.out.println(ns.length()) System.out.println System.out System System.out ns.length() ns.length ns String[] args args
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ns = s.substring(s.indexOf("A"),s.lastIndexOf("Z")+1);
		System.out.println(ns.length());
	}
}
