import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    }
} Main public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    } main {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int first = s.indexOf("A"); first s.indexOf("A") s.indexOf s "A" int last = s.lastIndexOf("Z"); last s.lastIndexOf("Z") s.lastIndexOf s "Z" System.out.println(last - first + 1) System.out.println System.out System System.out last - first + 1 last - first last first 1 String[] args args public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    }
} public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String s = sc.next(); 
        int first = s.indexOf("A");
        int last = s.lastIndexOf("Z");
        
        System.out.println(last - first + 1);
    }
}
