
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    }
	    	

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

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    }
	    	

	} Main public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    } main {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String a = scan.next(); a scan.next() scan.next scan String[] b = a.split(""); b a.split("") a.split a "" int c = 300000; c 300000 int d = 300000; d 300000 for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue; int i=0; int i=0; i 0 i<b.length i b.length b b.length i++ i++ i if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue; if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue; b[i].equals("A") b[i].equals b[i] b i "A" {
	    		c = i;
	    	break;
	    	} c = i c i break; continue; for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue; int j=b.length-1; int j=b.length-1; j b.length-1 b.length b b.length 1 j>=0 j 0 j-- j-- j if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue; if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue; b[j].equals("Z") b[j].equals b[j] b j "Z" {
		    		d = j;
	    	break;} d = j d j break; continue; d = d-c+1 d d-c+1 d-c d c 1 System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    }
	    	

	} public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    }
	    	

	} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    }
	    	

	}

