import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	}

	static void AZ(String[] param) {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	}

	static void AZ(String[] param) {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = ""; line "" int strN = 1; strN 1 for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		} int i = 0; int i = 0; i 0 i < strN i strN i++ i++ i {
			line += br.readLine() + " ";
		} {
			line += br.readLine() + " ";
		} line += br.readLine() + " " line br.readLine() + " " br.readLine() br.readLine br " " String[] param = line.split(" "); param line.split(" ") line.split line " " AZ(param) AZ param String[] args args static void AZ(String[] param) {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	} AZ {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	} System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1) System.out.println System.out System System.out (param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1 (param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) (param[0].lastIndexOf("Z")) param[0].lastIndexOf param[0] param 0 "Z" (param[0].indexOf("A")) param[0].indexOf param[0] param 0 "A" 1 String[] param param public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	}

	static void AZ(String[] param) {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	}

	static void AZ(String[] param) {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AZ(param);

	}

	static void AZ(String[] param) {

		System.out.println((param[0].lastIndexOf("Z")) - (param[0].indexOf("A")) + 1);
	}
}