import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	} main {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		} {
			sc.close();
		} sc.close() sc.close sc {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} String s = sc.next(); s sc.next() sc.next sc int idx = s.indexOf("A"); idx s.indexOf("A") s.indexOf s "A" int lstIdx = s.lastIndexOf("Z"); lstIdx s.lastIndexOf("Z") s.lastIndexOf s "Z" System.out.println(lstIdx - idx + 1) System.out.println System.out System System.out lstIdx - idx + 1 lstIdx - idx lstIdx idx 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();

			int idx = s.indexOf("A");
			int lstIdx = s.lastIndexOf("Z");

			System.out.println(lstIdx - idx + 1);

		} finally {
			sc.close();
		}
	}
}