import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc sc.close() sc.close sc int getAIndex = 0; getAIndex 0 int getZIndex = 0; getZIndex 0 char[] ch =s.toCharArray(); ch s.toCharArray() s.toCharArray s for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < ch.length i ch.length ch ch.length i++ i++ i {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		} {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		} if(ch[i] == 'A') {
				getAIndex = i;
				break;
			} ch[i] == 'A' ch[i] ch i 'A' {
				getAIndex = i;
				break;
			} getAIndex = i getAIndex i break; for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		} int i = ch.length-1; int i = ch.length-1; i ch.length-1 ch.length ch ch.length 1 i > 0 i 0 i-- i-- i {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		} {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		} if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			} ch[i] == 'Z' ch[i] ch i 'Z' {
				getZIndex = i;
				break;
			} getZIndex = i getZIndex i break; System.out.println(getZIndex - getAIndex + 1) System.out.println System.out System System.out getZIndex - getAIndex + 1 getZIndex - getAIndex getZIndex getAIndex 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int getAIndex = 0;
		int getZIndex = 0;
		char[] ch =s.toCharArray();
		for(int i = 0;i < ch.length;i++) {
			if(ch[i] == 'A') {
				getAIndex = i;
				break;
			}
		}
		for(int i = ch.length-1;i > 0;i--) {
			if(ch[i] == 'Z') {
				getZIndex = i;
				break;
			}
		}
		System.out.println(getZIndex - getAIndex + 1);
	}
}