import static java.lang.System.*;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	}
} import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; import java.util.Scanner; Scanner java.util public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	}
} Main public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	} main {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	} Scanner s = new Scanner(in); s new Scanner(in) String input = s.nextLine(); input s.nextLine() s.nextLine s int res = input.lastIndexOf("Z") - input.indexOf("A") + 1; res input.lastIndexOf("Z") - input.indexOf("A") + 1 input.lastIndexOf("Z") - input.indexOf("A") input.lastIndexOf("Z") input.lastIndexOf input "Z" input.indexOf("A") input.indexOf input "A" 1 out.println(res) out.println out res String[] args args public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	}
} public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	}
} Main
import static java.lang.System.*;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		String input = s.nextLine();
		
		int res = input.lastIndexOf("Z") - input.indexOf("A") + 1;
		
		out.println(res);
	}
}