import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	}

} Main public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br int str = line.length(); str line.length() line.length line int end = 0; end 0 for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		} int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		} {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		} if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			} line.charAt(i) == 'A' line.charAt(i) line.charAt line i 'A' {
				str = Math.min(str, i);
			} str = Math.min(str, i) str Math.min(str, i) Math.min Math str i if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			} line.charAt(i) == 'Z' line.charAt(i) line.charAt line i 'Z' {
				end = Math.max(end, i);

			} end = Math.max(end, i) end Math.max(end, i) Math.max Math end i System.out.println(end - str + 1) System.out.println System.out System System.out end - str + 1 end - str end str 1 String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	}

}
