import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        } sc.hasNext() sc.hasNext sc {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        } String s = sc.next(); s sc.next() sc.next sc int left = s.indexOf('A'); left s.indexOf('A') s.indexOf s 'A' int right = s.lastIndexOf('Z'); right s.lastIndexOf('Z') s.lastIndexOf s 'Z' System.out.println(right - left + 1) System.out.println System.out System System.out right - left + 1 right - left right left 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            int left = s.indexOf('A');
            int right = s.lastIndexOf('Z');
            System.out.println(right - left + 1);
        }
    }
}
