import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    } main {
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int a a z; z int i = 0; i 0 int j = s.length-1; j s.length-1 s.length s s.length 1 while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        } true {
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        } if(s[i] == 'A'){
              	a=i;
          		break;
            } s[i] == 'A' s[i] s i 'A' {
              	a=i;
          		break;
            } a=i a i break; i++ i while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        } true {
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        } if(s[j] == 'Z'){
            	z=j;
              	break;
            } s[j] == 'Z' s[j] s j 'Z' {
            	z=j;
              	break;
            } z=j z j break; j-- j System.out.println(j-i+1) System.out.println System.out System System.out j-i+1 j-i j i 1 String[] args args public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    }
}