import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    } main {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int start = str.indexOf("A"); start str.indexOf("A") str.indexOf str "A" int end = str.lastIndexOf("Z"); end str.lastIndexOf("Z") str.lastIndexOf str "Z" String substr = str.substring(start, end + 1); substr str.substring(start, end + 1) str.substring str start end + 1 end 1 System.out.println(substr.length()) System.out.println System.out System System.out substr.length() substr.length substr String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    }
}
