import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	}
} import java.util.Scanner; Scanner java.util import java.util.TreeSet; TreeSet java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	} main {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan TreeSet<Integer> A = new TreeSet<>(); A new TreeSet<>() TreeSet<Integer> Z = new TreeSet<>(); Z new TreeSet<>() for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		} {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		} if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			} s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
				A.add(i);
			} A.add(i) A.add A i if (s.charAt(i) == 'Z') {
				Z.add(i);
			} s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
				Z.add(i);
			} Z.add(i) Z.add Z i System.out.println(Z.last() - A.first() + 1) System.out.println System.out System System.out Z.last() - A.first() + 1 Z.last() - A.first() Z.last() Z.last Z A.first() A.first A 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	}
} Main
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Integer> A = new TreeSet<>();
		TreeSet<Integer> Z = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				A.add(i);
			} else if (s.charAt(i) == 'Z') {
				Z.add(i);
			}
		}
		System.out.println(Z.last() - A.first() + 1);

	}
}