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

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.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 {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		}
	}
} Main public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		}
	} main {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		}
	} try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		} {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String S = br.readLine(); S br.readLine() br.readLine br System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1) System.out.println System.out System System.out S.lastIndexOf("Z") - S.indexOf("A") + 1 S.lastIndexOf("Z") - S.indexOf("A") S.lastIndexOf("Z") S.lastIndexOf S "Z" S.indexOf("A") S.indexOf S "A" 1 String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

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

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String S = br.readLine();

			System.out.println(S.lastIndexOf("Z") - S.indexOf("A") + 1);
		}
	}
}