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 =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	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 =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	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 =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	int result=last-first+1;
    	
    	System.out.println(result);

    	scanner.close();


    } main {

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	int first =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	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 =input.indexOf("A"); first input.indexOf("A") input.indexOf input "A" int last=input.lastIndexOf("Z"); last input.lastIndexOf("Z") input.lastIndexOf input "Z" 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 =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	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 =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	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 =input.indexOf("A");
    	int last=input.lastIndexOf("Z");


    	int result=last-first+1;
    	
    	System.out.println(result);

    	scanner.close();


    }

}