import java.util.Scanner;
public class Main{
	String s;

	public Main(String str){
		s = str;
	}
	public int searchA(){
		return s.indexOf("A");
	}
	public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

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

	public Main(String str){
		s = str;
	}
	public int searchA(){
		return s.indexOf("A");
	}
	public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

	}
} Main String s; s public Main(String str){
		s = str;
	} Main {
		s = str;
	} s = str s str String str str public int searchA(){
		return s.indexOf("A");
	} searchA {
		return s.indexOf("A");
	} return s.indexOf("A"); s.indexOf("A") s.indexOf s "A" public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	} searchZ {
		return s.lastIndexOf("Z") + 1;
	} return s.lastIndexOf("Z") + 1; s.lastIndexOf("Z") + 1 s.lastIndexOf("Z") s.lastIndexOf s "Z" 1 public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

	} main {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan Main m = new Main(str); m new Main(str) int start = m.searchA(); start m.searchA() m.searchA m int end = m.searchZ(); end m.searchZ() m.searchZ m System.out.println(end - start) System.out.println System.out System System.out end - start end start String[] args args public class Main{
	String s;

	public Main(String str){
		s = str;
	}
	public int searchA(){
		return s.indexOf("A");
	}
	public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

	}
} public class Main{
	String s;

	public Main(String str){
		s = str;
	}
	public int searchA(){
		return s.indexOf("A");
	}
	public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

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

	public Main(String str){
		s = str;
	}
	public int searchA(){
		return s.indexOf("A");
	}
	public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		Main m = new Main(str);
		int start = m.searchA();
		int end = m.searchZ();
		System.out.println(end - start);

	}
}

