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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    } main {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s = scanner.next(); s scanner.next() scanner.next scanner scanner.close() scanner.close scanner Pattern p = Pattern.compile("[A][A-Z]*[Z]"); p Pattern.compile("[A][A-Z]*[Z]") Pattern.compile Pattern "[A][A-Z]*[Z]" Matcher matcher = p.matcher(s); matcher p.matcher(s) p.matcher p s int max = 0; max 0 while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        } matcher.find() matcher.find matcher {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        } int length = matcher.group().length(); length matcher.group().length() matcher.group().length matcher.group() matcher.group matcher if (max < length) {
                max = length;
            } max < length max length {
                max = length;
            } max = length max length System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    }
} Main
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    }
}
