
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	}
}
 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();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	} main {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int start = s.indexOf("A"); start s.indexOf("A") s.indexOf s "A" int end = s.lastIndexOf("Z"); end s.lastIndexOf("Z") s.lastIndexOf s "Z" String papapa = s.substring(start, end + 1); papapa s.substring(start, end + 1) s.substring s start end + 1 end 1 System.out.println(papapa.length()) System.out.println System.out System System.out papapa.length() papapa.length papapa String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	}
} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int start = s.indexOf("A");
		int end = s.lastIndexOf("Z");
		
		String papapa = s.substring(start, end + 1);
		System.out.println(papapa.length());
	}
}

