import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String s = sc.next(); s sc.next() sc.next sc final int N = s.length(); N s.length() s.length s int a = N; a N int z = 0; z 0 for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        } {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        } if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            } s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
                a = Math.min(a, i);
            } a = Math.min(a, i) a Math.min(a, i) Math.min Math a i if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
                z = Math.max(z, i);
            } z = Math.max(z, i) z Math.max(z, i) Math.max Math z i out.println(N > 2 ? z - a + 1 : N) out.println out N > 2 ? z - a + 1 : N N > 2 N 2 z - a + 1 z - a z a 1 N out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    }
}