import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Hashtable;
//https://vjudge.net/contest/159423#problem/B
public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} 
	


} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util import java.util.Hashtable; Hashtable java.util public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} 
	


} Main public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} main {
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String a = in.next(); a in.next() in.next in int firstA = 0; firstA 0 while(a.charAt(firstA) != 'A') {
			firstA++;
		} a.charAt(firstA) != 'A' a.charAt(firstA) a.charAt a firstA 'A' {
			firstA++;
		} firstA++ firstA int lastZ = a.length() - 1; lastZ a.length() - 1 a.length() a.length a 1 while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		} a.charAt(lastZ) != 'Z' a.charAt(lastZ) a.charAt a lastZ 'Z' {
			lastZ--;
		} lastZ-- lastZ System.out.println(lastZ - firstA + 1) System.out.println System.out System System.out lastZ - firstA + 1 lastZ - firstA lastZ firstA 1 String [] argv argv public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} 
	


} public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} 
	


} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Hashtable;
//https://vjudge.net/contest/159423#problem/B
public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} 
	


}
