import java.util.*;
public class Main {
    public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    }
} Main public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    } main {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int x = s.length(); x s.length() s.length s String[] arry = s.split(""); arry s.split("") s.split s "" boolean flag = false; flag false int h = 0; h 0 int o = 0; o 0 for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	} int i = 0; int i = 0; i 0 i < x i x i++ i++ i {
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	} {
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	} if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		} "A".equals(arry[i]) && flag == false "A".equals(arry[i]) "A".equals "A" arry[i] arry i flag == false flag false {
    			flag = true;
    			h = i;
    		} flag = true flag true h = i h i if("Z".equals(arry[i])) o = i; "Z".equals(arry[i]) "Z".equals "Z" arry[i] arry i o = i o i System.out.println(o-h+1) System.out.println System.out System System.out o-h+1 o-h o h 1 String[] args args public class Main {
    public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    }
} public class Main {
    public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//b
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int x = s.length();
    	String[] arry = s.split("");
    	boolean flag = false;
    	int h = 0;
    	int o = 0;
    	for(int i = 0; i < x; i++){
    		if("A".equals(arry[i]) && flag == false){
    			flag = true;
    			h = i;
    		}
    		if("Z".equals(arry[i])) o = i;
    	}
    	System.out.println(o-h+1);
    }
}