import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    }

}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    }

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

    	Main main=new Main();

    	main.run();

    } main {

    	Main main=new Main();

    	main.run();

    } Main main=new Main(); main new Main() main.run() main.run main String[] args args void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    } run {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String S=sc.next(); S sc.next() sc.next sc int first=S.indexOf("A"); first S.indexOf("A") S.indexOf S "A" int last=S.lastIndexOf("Z"); last S.lastIndexOf("Z") S.lastIndexOf S "Z" int result=last-first; result last-first last first System.out.println(result+1) System.out.println System.out System System.out result+1 result 1 public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    }

} public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    }

} Main
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

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

    	int result=last-first;

    	System.out.println(result+1);
    }

}

