import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	} main {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String s = stdIn.next(); s stdIn.next() stdIn.next stdIn char[] words = s.toCharArray(); words s.toCharArray() s.toCharArray s int min = 0; min 0 int max = 0; max 0 for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		} int i = s.length()-1; int i = s.length()-1; i s.length()-1 s.length() s.length s 1 i >= 0 i 0 i-- i-- i {
			if(words[i] == 'A') {
				min = i;
			}
		} {
			if(words[i] == 'A') {
				min = i;
			}
		} if(words[i] == 'A') {
				min = i;
			} words[i] == 'A' words[i] words i 'A' {
				min = i;
			} min = i min i for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			if(words[i] == 'Z') {
				max = i;
			}
		} {
			if(words[i] == 'Z') {
				max = i;
			}
		} if(words[i] == 'Z') {
				max = i;
			} words[i] == 'Z' words[i] words i 'Z' {
				max = i;
			} max = i max i System.out.println(max-min+1) System.out.println System.out System System.out max-min+1 max-min max min 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		char[] words = s.toCharArray();
		int min = 0;
		int max = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			if(words[i] == 'A') {
				min = i;
			}
		}
		for(int i = 0; i < s.length(); i++) {
			if(words[i] == 'Z') {
				max = i;
			}
		}
		System.out.println(max-min+1);

	}

}