import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    }
} Main public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    } main {
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan int A = Integer.MAX_VALUE; A Integer.MAX_VALUE Integer Integer.MAX_VALUE int Z = Integer.MIN_VALUE; Z Integer.MIN_VALUE Integer Integer.MIN_VALUE for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	} {
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	} if(s.charAt(i) == 'A' && i < A){
		A = i;
	    } s.charAt(i) == 'A' && i < A s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' i < A i A {
		A = i;
	    } A = i A i if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    } s.charAt(i) == 'Z' && i > Z s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' i > Z i Z {
		Z = i;
	    } Z = i Z i System.out.println(Z-A+1) System.out.println System.out System System.out Z-A+1 Z-A Z A 1 String[] args args public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    }
} public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int A = Integer.MAX_VALUE;
	int Z = Integer.MIN_VALUE;

	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) == 'A' && i < A){
		A = i;
	    }
	    if(s.charAt(i) == 'Z' && i > Z){
		Z = i;
	    }
	}

	System.out.println(Z-A+1);
    }
}
