import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int len = 0; len 0 int[] a = new int[200000]; a new int[200000] 200000 int[] z = new int[200000]; z new int[200000] 200000 int k = 0; k 0 int j = 0; j 0 for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		} {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		} char c = s.charAt(i); c s.charAt(i) s.charAt s i if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			} c == 'A' c 'A' {
				a[k] = i;
				k++;
			} a[k] = i a[k] a k i k++ k if(c == 'Z') {
				z[j] = i;
				j++;
			} c == 'Z' c 'Z' {
				z[j] = i;
				j++;
			} z[j] = i z[j] z j i j++ j len = z[j-1] - a[0] + 1 len z[j-1] - a[0] + 1 z[j-1] - a[0] z[j-1] z j-1 j 1 a[0] a 0 1 System.out.println(len) System.out.println System.out System System.out len String[] args args public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	}
} public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	}
}
