import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String s = in.next();
		int firstIdx = 0;
		while(firstIdx < s.length()) {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        }
      	int lastIdx = s.length() - 1;
        while(lastIdx > firstIdx) {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        }
        out.println(lastIdx - firstIdx + 1);
    }

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

class In {
    private BufferedInputStream reader = new BufferedInputStream(System.in);
    private byte[] buffer = new byte[0x8000];
    private int i = 0;
    private int length = 0;

    private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    }

    String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    }

    int nextInt() {
        return (int)nextLong();
    }

    long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
} import java.io.BufferedInputStream; BufferedInputStream java.io import java.io.IOException; IOException java.io import java.io.PrintWriter; PrintWriter java.io import java.util.StringJoiner; StringJoiner java.util import java.util.function.IntUnaryOperator; IntUnaryOperator java.util.function import java.util.function.LongUnaryOperator; LongUnaryOperator java.util.function class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String s = in.next();
		int firstIdx = 0;
		while(firstIdx < s.length()) {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        }
      	int lastIdx = s.length() - 1;
        while(lastIdx > firstIdx) {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        }
        out.println(lastIdx - firstIdx + 1);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
} Main static In in = new In(); in new In() static Out out = new Out(); out new Out() static long mod = 1000000007; mod 1000000007 static long inf = 0xfffffffffffffffL; inf 0xfffffffffffffffL void solve() {
        String s = in.next();
		int firstIdx = 0;
		while(firstIdx < s.length()) {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        }
      	int lastIdx = s.length() - 1;
        while(lastIdx > firstIdx) {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        }
        out.println(lastIdx - firstIdx + 1);
    } solve {
        String s = in.next();
		int firstIdx = 0;
		while(firstIdx < s.length()) {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        }
      	int lastIdx = s.length() - 1;
        while(lastIdx > firstIdx) {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        }
        out.println(lastIdx - firstIdx + 1);
    } String s = in.next(); s in.next() in.next in int firstIdx = 0; firstIdx 0 while(firstIdx < s.length()) {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        } firstIdx < s.length() firstIdx s.length() s.length s {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        } if(s.charAt(firstIdx) == 'A')
              break; s.charAt(firstIdx) == 'A' s.charAt(firstIdx) s.charAt s firstIdx 'A' break; firstIdx++ firstIdx int lastIdx = s.length() - 1; lastIdx s.length() - 1 s.length() s.length s 1 while(lastIdx > firstIdx) {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        } lastIdx > firstIdx lastIdx firstIdx {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        } if(s.charAt(lastIdx) == 'Z')
              break; s.charAt(lastIdx) == 'Z' s.charAt(lastIdx) s.charAt s lastIdx 'Z' break; lastIdx-- lastIdx out.println(lastIdx - firstIdx + 1) out.println out lastIdx - firstIdx + 1 lastIdx - firstIdx lastIdx firstIdx 1 public static void main(String[]$) {
        new Main().solve();
        out.flush();
    } main {
        new Main().solve();
        out.flush();
    } new Main().solve() new Main().solve new Main() out.flush() out.flush out String[]$ $ class In {
    private BufferedInputStream reader = new BufferedInputStream(System.in);
    private byte[] buffer = new byte[0x8000];
    private int i = 0;
    private int length = 0;

    private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    }

    String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    }

    int nextInt() {
        return (int)nextLong();
    }

    long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
} In private BufferedInputStream reader = new BufferedInputStream(System.in); reader new BufferedInputStream(System.in) private byte[] buffer = new byte[0x8000]; buffer new byte[0x8000] 0x8000 private int i = 0; i 0 private int length = 0; length 0 private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    } read {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    } if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        } i == length i length {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        } i = 0 i 0 try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            } catch (IOException ignored) {
            } IOException ignored {
            } {
                length = reader.read(buffer);
            } length = reader.read(buffer) length reader.read(buffer) reader.read reader buffer if (length == -1) {
                return -1;
            } length == -1 length -1 1 {
                return -1;
            } return -1; -1 1 return buffer[i++]; buffer[i++] buffer i++ i String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    } next {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    } StringBuilder builder = new StringBuilder(); builder new StringBuilder() int b = read(); b read() read while (b < '!' || '~' < b) {
            b = read();
        } b < '!' || '~' < b b < '!' b '!' '~' < b '~' b {
            b = read();
        } b = read() b read() read while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        } '!' <= b && b <= '~' '!' <= b '!' b b <= '~' b '~' {
            builder.appendCodePoint(b);
            b = read();
        } builder.appendCodePoint(b) builder.appendCodePoint builder b b = read() b read() read return builder.toString(); builder.toString() builder.toString builder int nextInt() {
        return (int)nextLong();
    } nextInt {
        return (int)nextLong();
    } return (int)nextLong(); (int)nextLong() nextLong long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    } nextLong {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    } int b = read(); b read() read while (b < '!' || '~' < b) {
            b = read();
        } b < '!' || '~' < b b < '!' b '!' '~' < b '~' b {
            b = read();
        } b = read() b read() read int i = 0; i 0 if (b == '-') {
            i = 1;
            b = read();
        } b == '-' b '-' {
            i = 1;
            b = read();
        } i = 1 i 1 b = read() b read() read long n = 0; n 0 while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        } '0' <= b && b <= '9' '0' <= b '0' b b <= '9' b '9' {
            n = n * 10 + b - '0';
            b = read();
        } n = n * 10 + b - '0' n n * 10 + b - '0' n * 10 + b n * 10 n 10 b '0' b = read() b read() read return i == 0 ? n : -n; i == 0 ? n : -n i == 0 i 0 n -n n char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    } nextCharArray {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    } char[][] a = new char[n][m]; a new char[n][m] n m for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = next().toCharArray();
        } {
            a[i] = next().toCharArray();
        } a[i] = next().toCharArray() a[i] a i next().toCharArray() next().toCharArray next() next return a; a int n n int m m int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    } nextIntArray {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    } int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = nextInt();
        } {
            a[i] = nextInt();
        } a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    } nextIntArray {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    } int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = op.applyAsInt(nextInt());
        } {
            a[i] = op.applyAsInt(nextInt());
        } a[i] = op.applyAsInt(nextInt()) a[i] a i op.applyAsInt(nextInt()) op.applyAsInt op nextInt() nextInt return a; a int n n IntUnaryOperator op op long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    } nextLongArray {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    } long[] a = new long[n]; a new long[n] n for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = nextLong();
        } {
            a[i] = nextLong();
        } a[i] = nextLong() a[i] a i nextLong() nextLong return a; a int n n long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    } nextLongArray {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    } long[] a = new long[n]; a new long[n] n for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = op.applyAsLong(nextLong());
        } {
            a[i] = op.applyAsLong(nextLong());
        } a[i] = op.applyAsLong(nextLong()) a[i] a i op.applyAsLong(nextLong()) op.applyAsLong op nextLong() nextLong return a; a int n n LongUnaryOperator op op class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
} Out private static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    } println {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    } StringJoiner joiner = new StringJoiner(" "); joiner new StringJoiner(" ") for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        } Object obj a {
            joiner.add(String.valueOf(obj));
        } {
            joiner.add(String.valueOf(obj));
        } joiner.add(String.valueOf(obj)) joiner.add joiner String.valueOf(obj) String.valueOf String obj out.println(joiner) out.println out joiner Object... a a void flush() {
        out.flush();
    } flush {
        out.flush();
    } out.flush() out.flush out
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String s = in.next();
		int firstIdx = 0;
		while(firstIdx < s.length()) {
        	if(s.charAt(firstIdx) == 'A')
              break;
          	firstIdx++;
        }
      	int lastIdx = s.length() - 1;
        while(lastIdx > firstIdx) {
          	if(s.charAt(lastIdx) == 'Z')
              break;
          	lastIdx--;
        }
        out.println(lastIdx - firstIdx + 1);
    }

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

class In {
    private BufferedInputStream reader = new BufferedInputStream(System.in);
    private byte[] buffer = new byte[0x8000];
    private int i = 0;
    private int length = 0;

    private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    }

    String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    }

    int nextInt() {
        return (int)nextLong();
    }

    long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}
