import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	} main {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc int count = 0; count 0 int flag = 0; flag 0 ArrayList<Integer> array = new ArrayList<Integer>(); array new ArrayList<Integer>() String[] param = a.split(""); param a.split("") a.split a "" for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		} {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		} if (param[i].equals("A")) {
				flag = i;
				break;
			} param[i].equals("A") param[i].equals param[i] param i "A" {
				flag = i;
				break;
			} flag = i flag i break; for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		} int j = flag; int j = flag; j flag j < a.length() j a.length() a.length a j++ j++ j {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		} {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		} count++ count if (param[j].equals("Z")) {
				array.add(count);
			} param[j].equals("Z") param[j].equals param[j] param j "Z" {
				array.add(count);
			} array.add(count) array.add array count Collections.sort(array) Collections.sort Collections array Collections.reverse(array) Collections.reverse Collections array System.out.println(array.get(0)) System.out.println System.out System System.out array.get(0) array.get array 0 String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		String[] param = a.split("");
		for (int i = 0; i < a.length(); i++) {
			if (param[i].equals("A")) {
				flag = i;
				break;
			}
		}
		for (int j = flag; j < a.length(); j++) {
			count++;
			if (param[j].equals("Z")) {
				array.add(count);
			}
		}
		Collections.sort(array);
		Collections.reverse(array);
		System.out.println(array.get(0));
	}
}