import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String sub;
		int max = -1;
		sub = s.substring(s.indexOf("A"), s.lastIndexOf("Z") + 1);
		max = sub.length();
		System.out.println(max);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String sub;
		int max = -1;
		sub = s.substring(s.indexOf("A"), s.lastIndexOf("Z") + 1);
		max = sub.length();
		System.out.println(max);
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String sub;
		int max = -1;
		sub = s.substring(s.indexOf("A"), s.lastIndexOf("Z") + 1);
		max = sub.length();
		System.out.println(max);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String sub; sub int max = -1; max -1 1 sub = s.substring(s.indexOf("A"), s.lastIndexOf("Z") + 1) sub 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 max = sub.length() max sub.length() sub.length sub System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {

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

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

public class Main {

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