

import java.util.Scanner;

public class Main {

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

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

		System.out.println(indexB - indexA);
    }
} import java.util.Scanner; Scanner java.util public class Main {

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

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

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

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

		System.out.println(indexB - indexA);
    } main {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

		System.out.println(indexB - indexA);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int indexA = 0; indexA 0 while(str.charAt(indexA) != 'A'){
			indexA++;
		} str.charAt(indexA) != 'A' str.charAt(indexA) str.charAt str indexA 'A' {
			indexA++;
		} indexA++ indexA int indexB = str.length(); indexB str.length() str.length str while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		} str.charAt(indexB - 1) != 'Z' str.charAt(indexB - 1) str.charAt str indexB - 1 indexB 1 'Z' {
			indexB--;
		} indexB-- indexB System.out.println(indexB - indexA) System.out.println System.out System System.out indexB - indexA indexB indexA String[] args args public class Main {

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

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

		System.out.println(indexB - indexA);
    }
} public class Main {

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

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

		System.out.println(indexB - indexA);
    }
} Main


import java.util.Scanner;

public class Main {

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

		String str = sc.next();

		int indexA = 0;
		while(str.charAt(indexA) != 'A'){
			indexA++;
		}
		int indexB = str.length();
		while(str.charAt(indexB - 1) != 'Z'){
			indexB--;
		}

		System.out.println(indexB - indexA);
    }
}