import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	}

} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String words = sc.next(); words sc.next() sc.next sc sc.close() sc.close sc ArrayList<Integer> AList = new ArrayList<>(); AList new ArrayList<>() ArrayList<Integer> ZList = new ArrayList<>(); ZList new ArrayList<>() for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		} int i = 0; int i = 0; i 0 i < words.length() i words.length() words.length words i++ i++ i {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		} {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		} char character = words.charAt(i); character words.charAt(i) words.charAt words i if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			} character == 'A' character 'A' {
				AList.add(i);
			} AList.add(i) AList.add AList i if(character == 'Z') {
				ZList.add(i);
			} character == 'Z' character 'Z' {
				ZList.add(i);
			} ZList.add(i) ZList.add ZList i int aa = AList.get(0); aa AList.get(0) AList.get AList 0 int zz = ZList.get(ZList.size()-1); zz ZList.get(ZList.size()-1) ZList.get ZList ZList.size()-1 ZList.size() ZList.size ZList 1 System.out.println(zz-aa+1) System.out.println System.out System System.out zz-aa+1 zz-aa zz aa 1 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	}

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String words = sc.next();
		sc.close();

		ArrayList<Integer> AList = new ArrayList<>();
		ArrayList<Integer> ZList = new ArrayList<>();

		for(int i = 0; i < words.length(); i++) {
			char character = words.charAt(i);

			if(character == 'A') {
				AList.add(i);
			}else if(character == 'Z') {
				ZList.add(i);
			}
		}

		int aa = AList.get(0);
		int zz = ZList.get(ZList.size()-1);

		System.out.println(zz-aa+1);

	}

}
