import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    }
} import java.util.Scanner; Scanner java.util public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    }
} Main public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    } main {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc s+=sc.nextLine() s sc.nextLine() sc.nextLine sc System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1) System.out.println System.out System System.out (s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1 (s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length()) s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))) s.substring s (s.indexOf('A')) s.indexOf s 'A' (s.lastIndexOf('Z')) s.lastIndexOf s 'Z' 1 String args[] args public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    }
} public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    }
} Main
import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s+=sc.nextLine();
        System.out.println((s.substring((s.indexOf('A')),(s.lastIndexOf('Z'))).length())+1);
    }
}