import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    } main {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = scan.next(); str scan.next() scan.next scan int i i j=str.length(); j str.length() str.length str for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        } i=0; i=0 i 0 i<str.length() i str.length() str.length str i++ i++ i {
            if(str.charAt(i)=='A')
            {
                break;
            }
        } {
            if(str.charAt(i)=='A')
            {
                break;
            }
        } if(str.charAt(i)=='A')
            {
                break;
            } str.charAt(i)=='A' str.charAt(i) str.charAt str i 'A' {
                break;
            } break; while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        } j>0 j 0 {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        } if(str.charAt(j-1)=='Z')
            {
                break;
            } str.charAt(j-1)=='Z' str.charAt(j-1) str.charAt str j-1 j 1 'Z' {
                break;
            } break; j-- j System.out.println(j-i) System.out.println System.out System System.out j-i j i String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String str = scan.next();
        
        int i,j=str.length();
        for(i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='A')
            {
                break;
            }
        }
        
        while(j>0)
        {
            if(str.charAt(j-1)=='Z')
            {
                break;
            }
            j--;
        }
        
        System.out.println(j-i);
    }
}