import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 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 start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 1);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 1);
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start = 0;
		int goal = 0;

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 1);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 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 start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 1);
	}

}
