import java.util.Scanner;

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

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	}
} Main public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	} main {
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s int start = 0; start 0 for(int i = 0; i < s.length(); i++){
			if(c[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(c[i] == 'A'){
				start = i;
				break;
			}
		} {
			if(c[i] == 'A'){
				start = i;
				break;
			}
		} if(c[i] == 'A'){
				start = i;
				break;
			} c[i] == 'A' c[i] c i 'A' {
				start = i;
				break;
			} start = i start i break; int end = 0; end 0 for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		} int i = s.length()-1; int i = s.length()-1; i s.length()-1 s.length() s.length s 1 i > start i start i-- i-- i {
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		} {
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		} if(c[i] == 'Z'){
				end = i;
				break;
			} c[i] == 'Z' c[i] c i 'Z' {
				end = i;
				break;
			} end = i end i break; System.out.println(end - start +1) System.out.println System.out System System.out end - start +1 end - start end start 1 String args[] args public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	}
} public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	}
} Main
import java.util.Scanner;

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

		String s = scan.next();
		char[] c = s.toCharArray();

		int start = 0;
		for(int i = 0; i < s.length(); i++){
			if(c[i] == 'A'){
				start = i;
				break;
			}
		}

		int end = 0;
		for(int i = s.length()-1; i > start; i--){
			if(c[i] == 'Z'){
				end = i;
				break;
			}
		}
		System.out.println(end - start +1);
	}
}
