import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    } main {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc boolean started = false; started false int len = 0; len 0 int index1 = 0 index1 0 index2; index2 for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        } int i=0; int i=0; i 0 i<a.length() i a.length() a.length a i++ i++ i {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        } {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        } if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            } !started && a.charAt(i) == 'A' !started started a.charAt(i) == 'A' a.charAt(i) a.charAt a i 'A' {
                started = true;
                index1 = i;
            } started = true started true index1 = i index1 i if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            } started && a.charAt(i) == 'Z' started a.charAt(i) == 'Z' a.charAt(i) a.charAt a i 'Z' {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            } started = true started true index2 = i index2 i len = index2 - index1 + 1 len index2 - index1 + 1 index2 - index1 index2 index1 1 System.out.println(len) System.out.println System.out System System.out len String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean started = false;
        int len = 0;
        int index1 = 0, index2;
        for (int i=0; i<a.length(); i++) {
            if (!started && a.charAt(i) == 'A') {
                started = true;
                index1 = i;
            }
            if (started && a.charAt(i) == 'Z') {
                started = true;
                index2 = i;
                len = index2 - index1 + 1;
            }
        }
        System.out.println(len);
    }
}
