import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    }

} Main public static void main(String[] args) {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    } main {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    } Scanner scanner=new Scanner(System.in); scanner new Scanner(System.in) String input=scanner.next(); input scanner.next() scanner.next scanner int first=0; first 0 int last=0; last 0 for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	} int i=0; int i=0; i 0 i<input.length() i input.length() input.length input i++ i++ i {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	} {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	} if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		} input.charAt(i)=='A' input.charAt(i) input.charAt input i 'A' {
    			first=i;
    			break;
    		} first=i first i break; for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	} int i=input.length()-1; int i=input.length()-1; i input.length()-1 input.length() input.length input 1 i>=0 i 0 i-- i-- i {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	} {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	} if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		} input.charAt(i)=='Z' input.charAt(i) input.charAt input i 'Z' {
    			last=i;
    			break;
    		} last=i last i break; int result=last-first+1; result last-first+1 last-first last first 1 System.out.println(result) System.out.println System.out System System.out result scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args) {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    }

} public class Main {
    public static void main(String[] args) {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first=0;
    	int last=0;

    	for(int i=0;i<input.length();i++) {
    		if(input.charAt(i)=='A') {
    			first=i;
    			break;
    		}
    	}

    	for(int i=input.length()-1;i>=0;i--) {
    		if(input.charAt(i)=='Z') {
    			last=i;
    			break;
    		}
    	}



    	int result=last-first+1;

    	System.out.println(result);

    	scanner.close();


    }

}