import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	}

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

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	}

} Main public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	} main {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char []a = s.toCharArray(); a s.toCharArray() s.toCharArray s int mina = s.length(); mina s.length() s.length s int maxz = 0; maxz 0 for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		} {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		} if(a[i] == 'A') {
				mina = Math.min(mina, i);
			} a[i] == 'A' a[i] a i 'A' {
				mina = Math.min(mina, i);
			} mina = Math.min(mina, i) mina Math.min(mina, i) Math.min Math mina i if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			} a[i] == 'Z' a[i] a i 'Z' {
				maxz = Math.max(maxz, i);
			} maxz = Math.max(maxz, i) maxz Math.max(maxz, i) Math.max Math maxz i System.out.println((maxz - mina) + 1) System.out.println System.out System System.out (maxz - mina) + 1 (maxz - mina) maxz mina 1 String[] args args public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	}

} public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	}

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

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	}

}
