import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        }
    } import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        }
    } Main public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        } main {
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc char[]ss = S.toCharArray(); ss S.toCharArray() S.toCharArray S ArrayList<Integer>a = new ArrayList<>(); a new ArrayList<>() ArrayList<Integer>z = new ArrayList<>(); z new ArrayList<>() for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        } int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        } {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        } if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	} ss[i] == 'A' ss[i] ss i 'A' {
        		a.add(i);
        	} a.add(i) a.add a i if(ss[i] == 'Z') {
            	z.add(i);
        	} ss[i] == 'Z' ss[i] ss i 'Z' {
            	z.add(i);
        	} z.add(i) z.add z i Collections.sort(a) Collections.sort Collections a Collections.sort(z,Collections.reverseOrder()) Collections.sort Collections z Collections.reverseOrder() Collections.reverseOrder Collections System.out.print(z.get(0) - a.get(0) + 1) System.out.print System.out System System.out z.get(0) - a.get(0) + 1 z.get(0) - a.get(0) z.get(0) z.get z 0 a.get(0) a.get a 0 1 String[] args args public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        }
    } public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        }
    } Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        }
    }
