import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		System.out.println(A.lastIndexOf("Z")-A.indexOf("A")+1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		System.out.println(A.lastIndexOf("Z")-A.indexOf("A")+1);
	} main {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		System.out.println(A.lastIndexOf("Z")-A.indexOf("A")+1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String A = sc.next(); A sc.next() sc.next sc System.out.println(A.lastIndexOf("Z")-A.indexOf("A")+1) System.out.println System.out System System.out A.lastIndexOf("Z")-A.indexOf("A")+1 A.lastIndexOf("Z")-A.indexOf("A") A.lastIndexOf("Z") A.lastIndexOf A "Z" A.indexOf("A") A.indexOf A "A" 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		System.out.println(A.lastIndexOf("Z")-A.indexOf("A")+1);
	}
} public class Main {

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		System.out.println(A.lastIndexOf("Z")-A.indexOf("A")+1);
	}
}
