import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	} main {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.nextLine(); s scan.nextLine() scan.nextLine scan boolean start = false; start false int startNum = 0; startNum 0 int finishNum = 0; finishNum 0 for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		} {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		} if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			} start == false && s.substring(i, i + 1).equals("A") start == false start false s.substring(i, i + 1).equals("A") s.substring(i, i + 1).equals s.substring(i, i + 1) s.substring s i i + 1 i 1 "A" {
				start = true;
				startNum = i;
			} start = true start true startNum = i startNum i if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			} start == true && s.substring(i, i + 1).equals("Z") start == true start true s.substring(i, i + 1).equals("Z") s.substring(i, i + 1).equals s.substring(i, i + 1) s.substring s i i + 1 i 1 "Z" {
				finishNum = i;
			} finishNum = i finishNum i System.out.println(finishNum - startNum + 1) System.out.println System.out System System.out finishNum - startNum + 1 finishNum - startNum finishNum startNum 1 scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	}

}
