import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String input = new String(scanner.next()); input new String(scanner.next()) Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ; output input.lastIndexOf('Z') - input.indexOf('A') + 1 input.lastIndexOf('Z') - input.indexOf('A') input.lastIndexOf('Z') input.lastIndexOf input 'Z' input.indexOf('A') input.indexOf input 'A' 1 System.out.println(output) System.out.println System.out System System.out output scanner.close() scanner.close scanner String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = new String(scanner.next());
		Integer output = input.lastIndexOf('Z') - input.indexOf('A') + 1 ;
		System.out.println(output);
		scanner.close();
	}
}
