import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int idx1 = 0; 
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        }

        int idx2 = 0; 
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        }
        
        System.out.println(idx2 - idx1 + 1);

        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int idx1 = 0; 
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        }

        int idx2 = 0; 
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        }
        
        System.out.println(idx2 - idx1 + 1);

        return;
    }

} Solver public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int idx1 = 0; 
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        }

        int idx2 = 0; 
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        }
        
        System.out.println(idx2 - idx1 + 1);

        return;
    } run {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int idx1 = 0; 
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        }

        int idx2 = 0; 
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        }
        
        System.out.println(idx2 - idx1 + 1);

        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int idx1 = 0; idx1 0 for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        } {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        } if (s[i] == 'A') {
                idx1 = i;
                break;
            } s[i] == 'A' s[i] s i 'A' {
                idx1 = i;
                break;
            } idx1 = i idx1 i break; int idx2 = 0; idx2 0 for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        } int i = s.length - 1; int i = s.length - 1; i s.length - 1 s.length s s.length 1 i >= 0 i 0 i-- i-- i {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        } {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        } if (s[i] == 'Z') {
                idx2 = i;
                break;
            } s[i] == 'Z' s[i] s i 'Z' {
                idx2 = i;
                break;
            } idx2 = i idx2 i break; System.out.println(idx2 - idx1 + 1) System.out.println System.out System System.out idx2 - idx1 + 1 idx2 - idx1 idx2 idx1 1 return;
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int idx1 = 0; 
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        }

        int idx2 = 0; 
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        }
        
        System.out.println(idx2 - idx1 + 1);

        return;
    }

}