import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 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 atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 1);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 1);
	} main {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int atA = 0; atA 0 int atZ = 0; atZ 0 for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		} int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		} {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		} if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			} String.valueOf(S.charAt(i)).equals("A") String.valueOf(S.charAt(i)).equals String.valueOf(S.charAt(i)) String.valueOf String S.charAt(i) S.charAt S i "A" {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			} atA = i atA i for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j < S.length() j S.length() S.length S j++ j++ j {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				} {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				} if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					} String.valueOf(S.charAt(j)).equals("Z") String.valueOf(S.charAt(j)).equals String.valueOf(S.charAt(j)) String.valueOf String S.charAt(j) S.charAt S j "Z" {
						atZ = j;
					} atZ = j atZ j break; System.out.println(atZ - atA + 1) System.out.println System.out System System.out atZ - atA + 1 atZ - atA atZ atA 1 String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 1);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 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 atA = 0;
		int atZ = 0;

		for (int i = 0; i < S.length(); i++) {
			if(String.valueOf(S.charAt(i)).equals("A")) {
				atA = i;
				for (int j = i + 1; j < S.length(); j++) {
					if(String.valueOf(S.charAt(j)).equals("Z")) {
						atZ = j;
					}
				}
				break;
			}
		}
		System.out.println(atZ - atA + 1);
	}
}
