import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int start = str.indexOf("A");
		int end = str.lastIndexOf("Z");
		
		System.out.println(end - start + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

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

		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int start = str.indexOf("A");
		int end = str.lastIndexOf("Z");
		
		System.out.println(end - start + 1);
	} main {

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int start = str.indexOf("A");
		int end = str.lastIndexOf("Z");
		
		System.out.println(end - start + 1);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int start = str.indexOf("A");
		int end = str.lastIndexOf("Z");
		
		System.out.println(end - start + 1);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int start = str.indexOf("A");
		int end = str.lastIndexOf("Z");
		
		System.out.println(end - start + 1);
	}
}
