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