import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    }
} import java.io.IOException; IOException java.io import java.util.NoSuchElementException; NoSuchElementException java.util import java.io.BufferedReader; BufferedReader java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    }
} Main public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    } main {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    } try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        } {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        } BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in)) BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in)) new BufferedReader(
                new InputStreamReader(System.in)) final String s = reader.readLine(); s reader.readLine() reader.readLine reader int atA = 200001; atA 200001 for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            } {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            } if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                } s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
                    atA = i;
                    break;
                } atA = i atA i break; int atZ = -1; atZ -1 1 for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            } int i = s.length() - 1; int i = s.length() - 1; i s.length() - 1 s.length() s.length s 1 0 <= i 0 i i-- i-- i {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            } {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            } if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
                    atZ = i;
                    break;
                } atZ = i atZ i break; System.out.println(atZ - atA + 1) System.out.println System.out System System.out atZ - atA + 1 atZ - atA atZ atA 1 String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    }
} Main
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int atA = 200001;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A') {
                    atA = i;
                    break;
                }
            }

            int atZ = -1;

            for (int i = s.length() - 1; 0 <= i; i--) {
                if (s.charAt(i) == 'Z') {
                    atZ = i;
                    break;
                }
            }

            System.out.println(atZ - atA + 1);
        }
    }
}
