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 checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	}

} 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 checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	} 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 checkA = 0; checkA 0 while(s.charAt(checkA) != 'A') {
			checkA++;
		} s.charAt(checkA) != 'A' s.charAt(checkA) s.charAt s checkA 'A' {
			checkA++;
		} checkA++ checkA int startA = checkA; startA checkA int checkZ = s.length() - 1; checkZ s.length() - 1 s.length() s.length s 1 while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		} s.charAt(checkZ) != 'Z' s.charAt(checkZ) s.charAt s checkZ 'Z' {
			checkZ--;
		} checkZ-- checkZ int lastZ = checkZ; lastZ checkZ int ans = lastZ - startA + 1; ans lastZ - startA + 1 lastZ - startA lastZ startA 1 System.out.println(ans) System.out.println System.out System System.out ans 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 checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	}

} 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 checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	}

}