import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x = sc.next(); x sc.next() sc.next sc int start = 0; start 0 int goal = 0; goal 0 for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		} {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		} if(x.charAt(i) == 'A') {
				start = i;
				break;
			} x.charAt(i) == 'A' x.charAt(i) x.charAt x i 'A' {
				start = i;
				break;
			} start = i start i break; for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		} int i = x.length() - 1; int i = x.length() - 1; i x.length() - 1 x.length() x.length x 1 i >= 0 i 0 i-- i-- i {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		} {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		} if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			} x.charAt(i) == 'Z' x.charAt(i) x.charAt x i 'Z' {
				goal = i;
				break;
			} goal = i goal i break; System.out.println(goal - start + 1) System.out.println System.out System System.out goal - start + 1 goal - start goal start 1 sc.close() sc.close sc void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	} debug {
		System.out.println(Arrays.deepToString(o));
	} System.out.println(Arrays.deepToString(o)) System.out.println System.out System System.out Arrays.deepToString(o) Arrays.deepToString Arrays o Object... o o public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int start = 0;
		int goal = 0;
		for(int i = 0; i < x.length(); i++) {
			if(x.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = x.length() - 1; i >= 0; i--) {
			if(x.charAt(i) == 'Z') {
				goal = i;
				break;
			}
		}
		System.out.println(goal - start + 1);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
