import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	}
} 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();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	} main {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

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

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	}
}