import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String s = sc.next();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+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();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+1);
    	}
    } Main public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String s = sc.next();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+1);
    	} main {
    		Scanner sc = new Scanner(System.in);
    		String s = sc.next();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+1);
    	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String tmp =""; tmp "" int start=0; start 0 int end=0; end 0 for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		} {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		} tmp=s.substring(i,i+1) tmp s.substring(i,i+1) s.substring s i i+1 i 1 if(tmp.equals("A")) {
    				start=i;
    				break;
    			} tmp.equals("A") tmp.equals tmp "A" {
    				start=i;
    				break;
    			} start=i start i break; for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		} int j=s.length()-1; int j=s.length()-1; j s.length()-1 s.length() s.length s 1 j>0 j 0 j-- j-- j {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		} {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		} tmp=s.substring(j,j+1) tmp s.substring(j,j+1) s.substring s j j+1 j 1 if(tmp.equals("Z")) {
    				end=j;
    				break;
    			} tmp.equals("Z") tmp.equals tmp "Z" {
    				end=j;
    				break;
    			} end=j end j break; System.out.println(end-start+1) System.out.println System.out System System.out end-start+1 end-start end start 1 String[] args args public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String s = sc.next();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+1);
    	}
    } public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String s = sc.next();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+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();
    		String tmp ="";
    		int start=0;
    		int end=0;
    		for (int i=0;i<s.length();i++) {
    			tmp=s.substring(i,i+1);
    			if(tmp.equals("A")) {
    				start=i;
    				break;
    			}
    		}
    		for(int j=s.length()-1;j>0;j--) {
    			tmp=s.substring(j,j+1);
    			if(tmp.equals("Z")) {
    				end=j;
    				break;
    			}
    		}
    		System.out.println(end-start+1);
    	}
    }