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