import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int ans = s.lastIndexOf('Z') - s.indexOf('A') + 1;

		//出力
		System.out.println(ans);
	}
} import java.util.*; util.* java class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int ans = s.lastIndexOf('Z') - s.indexOf('A') + 1;

		//出力
		System.out.println(ans);
	}
} Main public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int ans = s.lastIndexOf('Z') - s.indexOf('A') + 1;

		//出力
		System.out.println(ans);
	} main {
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int ans = s.lastIndexOf('Z') - s.indexOf('A') + 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 ans = s.lastIndexOf('Z') - s.indexOf('A') + 1; ans s.lastIndexOf('Z') - s.indexOf('A') + 1 s.lastIndexOf('Z') - s.indexOf('A') s.lastIndexOf('Z') s.lastIndexOf s 'Z' s.indexOf('A') s.indexOf s 'A' 1 System.out.println(ans) System.out.println System.out System System.out ans String[] $ $
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int ans = s.lastIndexOf('Z') - s.indexOf('A') + 1;

		//出力
		System.out.println(ans);
	}
}
