import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	} main {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb=new StringBuilder(sc.nextLine()); sb new StringBuilder(sc.nextLine()) int last=sb.lastIndexOf("Z"); last sb.lastIndexOf("Z") sb.lastIndexOf sb "Z" int first=sb.indexOf("A"); first sb.indexOf("A") sb.indexOf sb "A" System.out.println(last-first+1) System.out.println System.out System System.out last-first+1 last-first last first 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	}
}