import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     } main {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String[] s = S.split(""); s S.split("") S.split S "" boolean isa = true; isa true int a = 0; a 0 int z = 0; z 0 for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        } int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        } {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        } if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            } isa {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            } if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                } s[i].equals("A") s[i].equals s[i] s i "A" {
                    a = i;
                    isa = false;
                } a = i a i isa = false isa false if(s[i].equals("Z")) z = i; s[i].equals("Z") s[i].equals s[i] s i "Z" z = i z i System.out.println(z-a+1) System.out.println System.out System System.out z-a+1 z-a z a 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        boolean isa = true;
        int a = 0;
        int z = 0;
        for(int i=0; i<s.length; i++) {
            if(isa) {
                if(s[i].equals("A")) {
                    a = i;
                    isa = false;
                }
            }
            if(s[i].equals("Z")) z = i;
        }
        System.out.println(z-a+1);
     }
}