import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	}
 
} import java.util.*; util.* java public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	}
 
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int min = -1 min -1 1 max = 0; max 0 for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		} {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		} char c = s.charAt(i); c s.charAt(i) s.charAt s i if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i; c == 'A' && min < 0 c == 'A' c 'A' min < 0 min 0 min = i min i if(c == 'Z' && i > max) max= i; c == 'Z' && i > max c == 'Z' c 'Z' i > max i max max= i max i System.out.println(max - min + 1) System.out.println System.out System System.out max - min + 1 max - min max min 1 String[] args args public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	}
 
} public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	}
 
} Main
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	}
 
}