import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		
		
		int start = -1;
		int end = -1;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'A' && start == -1){
				start = i;
			}
			if(s.charAt(i) == 'Z' && start != -1){
				end = i;
			}
		}
		System.out.println(end-start+1);
	}

} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		
		
		int start = -1;
		int end = -1;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'A' && start == -1){
				start = i;
			}
			if(s.charAt(i) == 'Z' && start != -1){
				end = i;
			}
		}
		System.out.println(end-start+1);
	}

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

} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		
		
		int start = -1;
		int end = -1;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'A' && start == -1){
				start = i;
			}
			if(s.charAt(i) == 'Z' && start != -1){
				end = i;
			}
		}
		System.out.println(end-start+1);
	}

} Main
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		
		
		int start = -1;
		int end = -1;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'A' && start == -1){
				start = i;
			}
			if(s.charAt(i) == 'Z' && start != -1){
				end = i;
			}
		}
		System.out.println(end-start+1);
	}

}
