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 id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	}

}
 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 id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int id1 = 0; id1 0 int id2 = 0; id2 0 int hantei = 0; hantei 0 for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		} int i =0; int i =0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		} {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		} if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			} s.charAt(i) =='A' && hantei ==0 s.charAt(i) =='A' s.charAt(i) s.charAt s i 'A' hantei ==0 hantei 0 {
				hantei = 1;
				id1 =i;
			} hantei = 1 hantei 1 id1 =i id1 i if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			} s.charAt(i)=='Z' && hantei == 1 s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' hantei == 1 hantei 1 {
				id2 =i;
			} id2 =i id2 i System.out.println(id2-id1+1) System.out.println System.out System System.out id2-id1+1 id2-id1 id2 id1 1 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 id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	}

} 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 id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	}

} 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 id1 = 0;
		int id2 = 0;
		int hantei = 0;
		for(int i =0;i<s.length();i++) {
			if(s.charAt(i) =='A' && hantei ==0) {
				hantei = 1;
				id1 =i;
			}
			if(s.charAt(i)=='Z' && hantei == 1) {
				id2 =i;
			}
		}
		System.out.println(id2-id1+1);
		
	}

}

