import java.util.Scanner;

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

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	} main {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int n = c.length; n c.length c c.length int a a b; b a = b = 0 a b = 0 b 0 for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		} {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		} if (c[i] == 'A') {
				a = i;
				break;
			} c[i] == 'A' c[i] c i 'A' {
				a = i;
				break;
			} a = i a i break; for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		} int i = n - 1; int i = n - 1; i n - 1 n 1 0 <= i 0 i i-- i-- i {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		} {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		} if (c[i] == 'Z') {
				b = i;
				break;
			} c[i] == 'Z' c[i] c i 'Z' {
				b = i;
				break;
			} b = i b i break; System.out.println(b - a + 1) System.out.println System.out System System.out b - a + 1 b - a b a 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	}
} Main
import java.util.Scanner;

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

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int a, b;
		a = b = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = n - 1; 0 <= i; i--) {
			if (c[i] == 'Z') {
				b = i;
				break;
			}
		}
		System.out.println(b - a + 1);
	}
}
