import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = 0, z = 0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		sc.close();
	}
} 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 a = 0, z = 0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = 0, z = 0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = 0, z = 0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int a = 0 a 0 z = 0; z 0 for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = 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') {
				a = i;
				break;
			}
		} {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		} if(s.charAt(i)=='A') {
				a = i;
				break;
			} s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
				a = i;
				break;
			} a = i a i break; for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		} int i = s.length()-1; int i = s.length()-1; i s.length()-1 s.length() s.length s 1 i >= 0 i 0 i-- i-- i {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		} {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		} if(s.charAt(i)=='Z') {
				z = i;
				break;
			} s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
				z = i;
				break;
			} z = i z i break; System.out.println(z-a+1) System.out.println System.out System System.out z-a+1 z-a z a 1 sc.close() sc.close sc String[] args args public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = 0, z = 0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		sc.close();
	}
} 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 a = 0, z = 0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A') {
				a = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if(s.charAt(i)=='Z') {
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		sc.close();
	}
}