import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	}
} 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();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int f = -1; f -1 1 int l = -1; l -1 1 for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = 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' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		} {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		} if (s.charAt(i) == 'A' &&f < 0 ) f = i; s.charAt(i) == 'A' &&f < 0 s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' f < 0 f 0 f = i f i if (s.charAt(i) == 'Z') l = i; s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' l = i l i System.out.println(l+1-f) System.out.println System.out System System.out l+1-f l+1 l 1 f String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int f = -1; int l = -1;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == 'A' &&f < 0 ) f = i;
			if (s.charAt(i) == 'Z') l = i;
		}
		System.out.println(l+1-f);
	}
}
