import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	int Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+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 Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+1);
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	int Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+1);
    } main {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	int Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc int Znum = 0; Znum 0 for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	} int i = S.length()-1; int i = S.length()-1; i S.length()-1 S.length() S.length S 1 0 < i 0 i i-- i-- i {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	} {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	} if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		} S.charAt(i) == 'Z' S.charAt(i) S.charAt S i 'Z' {
    			Znum = i;
    			break;
    		} Znum = i Znum i break; System.out.println(Znum - S.indexOf("A")+1) System.out.println System.out System System.out Znum - S.indexOf("A")+1 Znum - S.indexOf("A") Znum S.indexOf("A") S.indexOf S "A" 1 String[] args args public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	int Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+1);
    }
} public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	int Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+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 Znum = 0;
    	for (int i = S.length()-1; 0 < i; i--) {
    		if (S.charAt(i) == 'Z') {
    			Znum = i;
    			break;
    		}
    	}
    	System.out.println(Znum - S.indexOf("A")+1);
    }
}