import java.util.*;

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

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