import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    } main {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    } Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scan new Scanner(new BufferedReader(new InputStreamReader(System.in))) String s = scan.next(); s scan.next() scan.next scan int start = s.indexOf("A"); start s.indexOf("A") s.indexOf s "A" int end = s.lastIndexOf("Z"); end s.lastIndexOf("Z") s.lastIndexOf s "Z" System.out.println(end - start + 1) System.out.println System.out System System.out end - start + 1 end - start end start 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int start = s.indexOf("A");
        int end = s.lastIndexOf("Z");
        System.out.println(end - start + 1);
    }
}
