import java.util.Scanner;

/**
 * https://abc053.contest.atcoder.jp/tasks/abc053_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	}

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

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	}

} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	} main {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc sc.close() sc.close sc int s = str.indexOf('A'); s str.indexOf('A') str.indexOf str 'A' int e = str.lastIndexOf('Z'); e str.lastIndexOf('Z') str.lastIndexOf str 'Z' System.out.println(e-s+1) System.out.println System.out System System.out e-s+1 e-s e s 1 String[] args args public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	}

} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	}

} Main
import java.util.Scanner;

/**
 * https://abc053.contest.atcoder.jp/tasks/abc053_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		int s = str.indexOf('A');
		int e = str.lastIndexOf('Z');
		
		System.out.println(e-s+1);

	}

}
