import java.util.Scanner;

class Main{




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		
		int anum = 0;
		for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		}
		
		int znum = 0;
		for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		}
		
		System.out.println(znum-anum+1);


	}
}


class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}

 import java.util.Scanner; Scanner java.util class Main{




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		
		int anum = 0;
		for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		}
		
		int znum = 0;
		for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		}
		
		System.out.println(znum-anum+1);


	}
} Main public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		
		int anum = 0;
		for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		}
		
		int znum = 0;
		for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		}
		
		System.out.println(znum-anum+1);


	} main {





		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		
		int anum = 0;
		for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		}
		
		int znum = 0;
		for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		}
		
		System.out.println(znum-anum+1);


	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc int anum = 0; anum 0 for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		} {
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		} if(a.charAt(i) == 'A'){
				anum = i;
				break;
			} a.charAt(i) == 'A' a.charAt(i) a.charAt a i 'A' {
				anum = i;
				break;
			} anum = i anum i break; int znum = 0; znum 0 for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		} int i = a.length()-1; int i = a.length()-1; i a.length()-1 a.length() a.length a 1 i >= 0 i 0 i-- i-- i {
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		} {
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		} if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			} a.charAt(i) == 'Z' a.charAt(i) a.charAt a i 'Z' {
				znum = i;
				break;
			} znum = i znum i break; System.out.println(znum-anum+1) System.out.println System.out System System.out znum-anum+1 znum-anum znum anum 1 String[] args args class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
} Pair Character from; from int end; end @Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	} compareTo {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	} Pair otherpair = (Pair)other; otherpair (Pair)other return end - otherpair.end; end - otherpair.end end otherpair.end otherpair otherpair.end Object other other Comparable
import java.util.Scanner;

class Main{




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		
		int anum = 0;
		for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		}
		
		int znum = 0;
		for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		}
		
		System.out.println(znum-anum+1);


	}
}


class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


