// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
        int ans=0;
        int aind=-1;
        int zind=-1;
        
        for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        }
		System.out.println(zind-aind+1);        
    
    }
}
 import java.util.*; util.* java import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
        int ans=0;
        int aind=-1;
        int zind=-1;
        
        for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        }
		System.out.println(zind-aind+1);        
    
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
        int ans=0;
        int aind=-1;
        int zind=-1;
        
        for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        }
		System.out.println(zind-aind+1);        
    
    } main {
        Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
        int ans=0;
        int aind=-1;
        int zind=-1;
        
        for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        }
		System.out.println(zind-aind+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 sc.close() sc.close sc int ans=0; ans 0 int aind=-1; aind -1 1 int zind=-1; zind -1 1 for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        } int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i {
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        } {
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        } if (s[i]=='A' && aind==-1){
                aind=i;
            } s[i]=='A' && aind==-1 s[i]=='A' s[i] s i 'A' aind==-1 aind -1 1 {
                aind=i;
            } aind=i aind i if (s[i]=='Z'){
                zind=i;
            } s[i]=='Z' s[i] s i 'Z' {
                zind=i;
            } zind=i zind i System.out.println(zind-aind+1) System.out.println System.out System System.out zind-aind+1 zind-aind zind aind 1 String[] args args
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
        int ans=0;
        int aind=-1;
        int zind=-1;
        
        for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        }
		System.out.println(zind-aind+1);        
    
    }
}

