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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	} main {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	} BufferedReader vf = new BufferedReader(new InputStreamReader(System.in)); vf new BufferedReader(new InputStreamReader(System.in)) String aou = vf.readLine(); aou vf.readLine() vf.readLine vf int f = aou.indexOf("A"); f aou.indexOf("A") aou.indexOf aou "A" StringBuffer sb = new StringBuffer(aou); sb new StringBuffer(aou) StringBuffer eou = sb.reverse(); eou sb.reverse() sb.reverse sb int e = eou.indexOf("Z"); e eou.indexOf("Z") eou.indexOf eou "Z" int o = aou.length() - f - e; o aou.length() - f - e aou.length() - f - e aou.length() aou.length aou f e System.out.println(o) System.out.println System.out System System.out o String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	}

} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));

		String aou = vf.readLine();

		int f = aou.indexOf("A");

		StringBuffer sb = new StringBuffer(aou);
		StringBuffer eou = sb.reverse();

		int e = eou.indexOf("Z");

		int o = aou.length() - f - e;

		System.out.println(o);

	}

}
