import java.util.Scanner;

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

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	}

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

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	} main {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int acount=0; acount 0 int zcount =300000; zcount 300000 for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		} {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		} if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			} String.valueOf(str.charAt(i)).equals("A") String.valueOf(str.charAt(i)).equals String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i "A" {
				acount =i;
				break;
			} acount =i acount i break; for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		} int i=str.length()-1; int i=str.length()-1; i str.length()-1 str.length() str.length str 1 i>=0 i 0 i-- i-- i {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		} {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		} if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			} String.valueOf(str.charAt(i)).equals("Z") String.valueOf(str.charAt(i)).equals String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i "Z" {
				zcount =i;
				break;
			} zcount =i zcount i break; System.out.print(zcount-acount+1) System.out.print System.out System System.out zcount-acount+1 zcount-acount zcount acount 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	}

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

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	}

} Main
import java.util.Scanner;

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

		String str = sc.next();

		int acount=0;
		int zcount =300000;

		for(int i=0;i<str.length();i++) {
			if(String.valueOf(str.charAt(i)).equals("A")){
				acount =i;
				break;
			}
		}

		for(int i=str.length()-1; i>=0;i--) {
			if(String.valueOf(str.charAt(i)).equals("Z")){
				zcount =i;
				break;
			}
		}

		System.out.print(zcount-acount+1);
	}

}