import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	}
} Main public static final long MOD =  1000000007L; MOD 1000000007L public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	} main {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	} int i i j j k k l; l Scanner sc = new Scanner(in); sc new Scanner(in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc sc.close() sc.close sc for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		} i = 0; i = 0 i 0 i < s.length i s.length s s.length i++ i++ i {
			if(s[i]=='A')break;
		} {
			if(s[i]=='A')break;
		} if(s[i]=='A')break; s[i]=='A' s[i] s i 'A' break; int sta=i; sta i for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		} i = s.length-1; i = s.length-1 i s.length-1 s.length s s.length 1 i >= 0 i 0 i-- i-- i {
			if(s[i]=='Z')break;
		} {
			if(s[i]=='Z')break;
		} if(s[i]=='Z')break; s[i]=='Z' s[i] s i 'Z' break; int end=i; end i out.println(end-sta+1) out.println out end-sta+1 end-sta end sta 1 String[] args args public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	}
} public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		for (i = 0; i < s.length; i++) {
			if(s[i]=='A')break;
		}
		int sta=i;
		for (i = s.length-1; i >= 0; i--) {
			if(s[i]=='Z')break;
		}
		int end=i;
		out.println(end-sta+1);
	}
}
