import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    }
} Main public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    } solve {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char c[] = s.toCharArray(); c s.toCharArray() s.toCharArray s int a = 0; a 0 int b = 0; b 0 for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        } {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        } if (c[i] == 'A') {
                a = i + 1;
                break;
            } c[i] == 'A' c[i] c i 'A' {
                a = i + 1;
                break;
            } a = i + 1 a i + 1 i 1 break; for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        } int i = s.length() - 1; int i = s.length() - 1; i s.length() - 1 s.length() s.length s 1 i >= 0 i 0 i-- i-- i {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        } {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        } if (c[i] == 'Z') {
                b = i + 1;
                break;
            } c[i] == 'Z' c[i] c i 'Z' {
                b = i + 1;
                break;
            } b = i + 1 b i + 1 i 1 break; System.out.println(b - a + 1) System.out.println System.out System System.out b - a + 1 b - a b a 1 public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    }
} public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c[] = s.toCharArray();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (c[i] == 'A') {
                a = i + 1;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (c[i] == 'Z') {
                b = i + 1;
                break;
            }
        }
        System.out.println(b - a + 1);
    }
}