import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset import java.util.*; util.* java public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
} Main int[] inputArray; inputArray Set<String> set = new HashSet<>(); set new HashSet<>() int K; K public static void main(String[] args) throws IOException {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    } run {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] array = sc.next().toCharArray(); array sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc StringBuilder str = new StringBuilder(); str new StringBuilder() int firstA = -1; firstA -1 1 int lastZ = -1; lastZ -1 1 for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        } int i=0; int i=0; i 0 i<array.length i array.length array array.length i++ i++ i {
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        } {
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        } String s = String.valueOf(array[i]); s String.valueOf(array[i]) String.valueOf String array[i] array i if(s.equals("A") && firstA == -1) firstA = i; s.equals("A") && firstA == -1 s.equals("A") s.equals s "A" firstA == -1 firstA -1 1 firstA = i firstA i if(s.equals("Z")) lastZ = i; s.equals("Z") s.equals s "Z" lastZ = i lastZ i for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        } int i=firstA; int i=firstA; i firstA i<=lastZ i lastZ i++ i++ i {
            str.append(String.valueOf(array[i]));
        } {
            str.append(String.valueOf(array[i]));
        } str.append(String.valueOf(array[i])) str.append str String.valueOf(array[i]) String.valueOf String array[i] array i System.out.println(str.length()) System.out.println System.out System System.out str.length() str.length str double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    } manhattan {
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    } return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY()); Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY()) Math.abs(point1.getX() - point2.getX()) Math.abs Math point1.getX() - point2.getX() point1.getX() point1.getX point1 point2.getX() point2.getX point2 Math.abs(point1.getY() - point2.getY()) Math.abs Math point1.getY() - point2.getY() point1.getY() point1.getY point1 point2.getY() point2.getY point2 Ten point1 point1 Ten point2 point2 void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    } substring {
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    } for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        } int i=1; int i=1; i 1 i<=num i num i++ i++ i {
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        } {
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        } if(i > K){
                break;
            } i > K i K {
                break;
            } break; for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            } int j=0; int j=0; j 0 j<num j num j++ j++ j {
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            } {
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            } if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                } j + i-1 < num j + i-1 j + i j i 1 num {
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } set.add(s.substring(j, j+i)) set.add set s.substring(j, j+i) s.substring s j j+i j i {
                    break;
                } break; String s s int num num void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    } permutation {
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    } if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        } s.length() <= 1 s.length() s.length s 1 {
            System.out.println(ans + s);
        } System.out.println(ans + s) System.out.println System.out System System.out ans + s ans s {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        } for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            } {
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            } permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i)) permutation s.substring(0, i) + s.substring(i + 1) s.substring(0, i) s.substring s 0 i s.substring(i + 1) s.substring s i + 1 i 1 ans + s.charAt(i) ans s.charAt(i) s.charAt s i String s s String ans ans class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
} Ten private int x; x private int y; y Ten(int x, int y){
        this.x = x;
        this.y = y;
    } Ten {
        this.x = x;
        this.y = y;
    } this.x = x this.x this this.x x this.y = y this.y this this.y y int x x int y y public int getX() {
        return x;
    } getX {
        return x;
    } return x; x public void setX(int x) {
        this.x = x;
    } setX {
        this.x = x;
    } this.x = x this.x this this.x x int x x public int getY() {
        return y;
    } getY {
        return y;
    } return y; y public void setY(int y) {
        this.y = y;
    } setY {
        this.y = y;
    } this.y = y this.y this this.y y int y y public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
} public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        StringBuilder str = new StringBuilder();

        int firstA = -1;
        int lastZ = -1;

        for(int i=0; i<array.length; i++){
            String s = String.valueOf(array[i]);
            if(s.equals("A") && firstA == -1) firstA = i;
            if(s.equals("Z")) lastZ = i;
        }

        for(int i=firstA; i<=lastZ; i++){
            str.append(String.valueOf(array[i]));
        }

        System.out.println(str.length());
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}