import java.util.*;
public class Main {

	public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	}

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

	public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	}

} Main public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	} main {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc int j=s.length()-1; j s.length()-1 s.length() s.length s 1 int ind1=0; ind1 0 int count=0; count 0 int count2=0; count2 0 int ind2=0; ind2 0 for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			} int i=0; int i=0; i 0 i<j+1 i j+1 j 1 i++ i++ i {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			} {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			} if(s.charAt(i)=='A') {
					ind1=i;
					break;
				} s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
					ind1=i;
					break;
				} ind1=i ind1 i break; for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			} int i=j; int i=j; i j i>=0 i 0 i-- i-- i {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			} {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			} if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				} s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
					ind2=i;
					break;
				} ind2=i ind2 i break; if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			} ind2-ind1!=0 ind2-ind1 ind2 ind1 0 {
			System.out.println(ind2-ind1+1);
			} System.out.println(ind2-ind1+1) System.out.println System.out System System.out ind2-ind1+1 ind2-ind1 ind2 ind1 1 String[] args args public class Main {

	public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	}

} public class Main {

	public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	}

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

	public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
			String s=sc.next();
			
			int j=s.length()-1;
			int ind1=0;
			int count=0;
			int count2=0;
			int ind2=0;
			for(int i=0;i<j+1;i++) {
				if(s.charAt(i)=='A') {
					ind1=i;
					break;
				}
			}	for(int i=j;i>=0;i--) {
				if(s.charAt(i)=='Z') {
					ind2=i;
					break;
				}
			}
			if(ind2-ind1!=0) {
			System.out.println(ind2-ind1+1);
			}

	}

}
