import java.util.*;
public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int min = S.length;
		int max = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		}
		System.out.println(max - min + 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int min = S.length;
		int max = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		}
		System.out.println(max - min + 1);
	} main {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int min = S.length;
		int max = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		}
		System.out.println(max - min + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] S = sc.next().toCharArray(); S sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int min = S.length; min S.length S S.length int max = 0; max 0 for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		} int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		} {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		} if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; S[i] == 'A' && min > i S[i] == 'A' S[i] S i 'A' min > i min i min = i min i if(S[i] == 'Z' && max < i) max = i; S[i] == 'Z' && max < i S[i] == 'Z' S[i] S i 'Z' max < i 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 sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int min = S.length;
		int max = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		}
		System.out.println(max - min + 1);
	}
} public class Main {

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

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