import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.List; List java.util class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
} Main public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    } main {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    } try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } IOException | NumberFormatException e {
            e.printStackTrace();
            System.exit(0);
        } e.printStackTrace() e.printStackTrace e System.exit(0) System.exit System 0 catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        } final Exception e {
            e.printStackTrace();
            System.exit(0);
        } e.printStackTrace() e.printStackTrace e System.exit(0) System.exit System 0 {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) List<String> inputString = Arrays.asList(br.readLine().split("")); inputString Arrays.asList(br.readLine().split("")) Arrays.asList Arrays br.readLine().split("") br.readLine().split br.readLine() br.readLine br "" int start = 0; start 0 int end = 0; end 0 for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            } int i = 0; int i = 0; i 0 i < inputString.size() i inputString.size() inputString.size inputString i++ i++ i {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            } {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            } if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                } inputString.get(i).equals("A") inputString.get(i).equals inputString.get(i) inputString.get inputString i "A" {
                    start = i;
                    break;
                } start = i start i break; for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            } int j = inputString.size() - 1; int j = inputString.size() - 1; j inputString.size() - 1 inputString.size() inputString.size inputString 1 j > start j start j-- j-- j {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            } {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            } if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                } inputString.get(j).equals("Z") inputString.get(j).equals inputString.get(j) inputString.get inputString j "Z" {
                    end = j;
                    break;
                } end = j end j break; int ans = end - start + 1; ans end - start + 1 end - start end start 1 System.out.println(ans) System.out.println System.out System System.out ans final String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}