
import java.util.Scanner;

public class Main {

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

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

	} main {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int check=0;
		int a=0,z=0;
		for(int i=0;i<s.length();i++) {
			if(check>=1)check++;
			if(check==0&&s.charAt(i)=='A') {
				a=i;
				check=1;
			}
			else if(check>=1&&s.charAt(i)=='Z')z=i;
		}
		System.out.println(z-a+1);

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

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

	}
} public class Main {

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

	}
}
