import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    } main {
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan int num = s.length(); num s.length() s.length s int min = 10; min 10 int max = 0; max 0 for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        } {
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        } if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            } s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
            	min = i;	
              	break;
            } min = i min i break; for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        } {
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        } if(s.charAt(i) == 'Z'){
            	max = i;
            } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
            	max = i;
            } max = i max i System.out.print(max - min + 1) System.out.print System.out System System.out max - min + 1 max - min max min 1 String[] args args public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    }
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    }
}