import java.util.Scanner;

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