import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Pattern p = Pattern.compile("A[A-Z]*Z");
        Matcher m = p.matcher(s);
        if (m.find()) {
            System.out.println(m.group().length());
        }
    }
} import java.util.*; util.* java import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Pattern p = Pattern.compile("A[A-Z]*Z");
        Matcher m = p.matcher(s);
        if (m.find()) {
            System.out.println(m.group().length());
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Pattern p = Pattern.compile("A[A-Z]*Z");
        Matcher m = p.matcher(s);
        if (m.find()) {
            System.out.println(m.group().length());
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Pattern p = Pattern.compile("A[A-Z]*Z");
        Matcher m = p.matcher(s);
        if (m.find()) {
            System.out.println(m.group().length());
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc Pattern p = Pattern.compile("A[A-Z]*Z"); p Pattern.compile("A[A-Z]*Z") Pattern.compile Pattern "A[A-Z]*Z" Matcher m = p.matcher(s); m p.matcher(s) p.matcher p s if (m.find()) {
            System.out.println(m.group().length());
        } m.find() m.find m {
            System.out.println(m.group().length());
        } System.out.println(m.group().length()) System.out.println System.out System System.out m.group().length() m.group().length m.group() m.group m String[] args args
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Pattern p = Pattern.compile("A[A-Z]*Z");
        Matcher m = p.matcher(s);
        if (m.find()) {
            System.out.println(m.group().length());
        }
    }
}