import java.util.Scanner;

public class Main {

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

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

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

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

public class Main {

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