import java.util.Scanner;

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 idx=0, idx2=0;
		boolean a=false;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='A' && !a) {
				a=true;
				idx=i;
			}
			if(s.charAt(i)=='Z' && a) {
				idx2=i;
			}
		}
		System.out.println(idx2-idx+1);
		
	}

} import java.util.Scanner; Scanner 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 idx=0, idx2=0;
		boolean a=false;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='A' && !a) {
				a=true;
				idx=i;
			}
			if(s.charAt(i)=='Z' && a) {
				idx2=i;
			}
		}
		System.out.println(idx2-idx+1);
		
	}

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

} Main
import java.util.Scanner;

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 idx=0, idx2=0;
		boolean a=false;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='A' && !a) {
				a=true;
				idx=i;
			}
			if(s.charAt(i)=='Z' && a) {
				idx2=i;
			}
		}
		System.out.println(idx2-idx+1);
		
	}

}
