import java.util.Scanner;

public class Main {

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

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

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

} public class Main {

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

} Main
import java.util.Scanner;

public class Main {

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

}
