import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +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();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +1);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int startA = 0; startA 0 boolean isA = false; isA false int endZ = 0; endZ 0 for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        } {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        } if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            } !isA && "A".equals(s.substring(i,i+1)) !isA isA "A".equals(s.substring(i,i+1)) "A".equals "A" s.substring(i,i+1) s.substring s i i+1 i 1 {
                startA = i;
                isA = true;
            } startA = i startA i isA = true isA true if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            } "Z".equals(s.substring(i,i+1)) "Z".equals "Z" s.substring(i,i+1) s.substring s i i+1 i 1 {
                endZ = i;
            } endZ = i endZ i System.out.println(endZ - startA +1) System.out.println System.out System System.out endZ - startA +1 endZ - startA endZ startA 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +1);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int startA = 0;
        boolean isA = false;
        int endZ = 0;
        for (int i=0; i<s.length();i++) {
            if (!isA && "A".equals(s.substring(i,i+1))) {
                startA = i;
                isA = true;
            } else if ("Z".equals(s.substring(i,i+1))) {
                endZ = i;
            }
        }
        System.out.println(endZ - startA +1);
    }
}