import java.util.*;
public class Main {

	public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	}

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

	public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	} main {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	} int a=0 a 0 b=0 b 0 ans=0; ans 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String c = sc.next(); c sc.next() sc.next sc a = c.indexOf('A') a c.indexOf('A') c.indexOf c 'A' for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		} int i = a+1; int i = a+1; i a+1 a 1 i < c.length() i c.length() c.length c i++ i++ i {
			if(c.charAt(i) == 'Z')b = i;
		} {
			if(c.charAt(i) == 'Z')b = i;
		} if(c.charAt(i) == 'Z')b = i; c.charAt(i) == 'Z' c.charAt(i) c.charAt c i 'Z' b = i b i ans = b - a + 1 ans b - a + 1 b - a b a 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	}

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

	public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	}

}
