import java.io.*;
import java.util.*;

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	} main {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc int index = str.indexOf('A'); index str.indexOf('A') str.indexOf str 'A' int count = 1; count 1 for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		} int i = index; int i = index; i index i < str.length() i str.length() str.length str i++ i++ i {
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		} {
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		} if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			} str.charAt(i)=='Z' str.charAt(i) str.charAt str i 'Z' {
				count = i -index +1;

			} count = i -index +1 count i -index +1 i -index i index 1 System.out.print(count) System.out.print System.out System System.out count String[] args args public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	}
} public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	}
} Main
import java.io.*;
import java.util.*;

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int index = str.indexOf('A');
		int count = 1;
		for (int i = index; i < str.length(); i++ )
		{
			if(str.charAt(i)=='Z')
			{
				count = i -index +1;

			}
		}
		System.out.print(count);
	}
}