import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	} main {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan int indA = str.indexOf('A'); indA str.indexOf('A') str.indexOf str 'A' int indZ = str.lastIndexOf('Z'); indZ str.lastIndexOf('Z') str.lastIndexOf str 'Z' System.out.println(indZ-indA + 1) System.out.println System.out System System.out indZ-indA + 1 indZ-indA indZ indA 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int indA = str.indexOf('A');
		int indZ = str.lastIndexOf('Z');
		System.out.println(indZ-indA + 1);
	}
}
