
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    }
} Main public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw new BufferedWriter(new OutputStreamWriter(System.out)) Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = br.readLine(); str br.readLine() br.readLine br System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1) System.out.println System.out System System.out str.lastIndexOf("Z") - str.indexOf("A") + 1 str.lastIndexOf("Z") - str.indexOf("A") str.lastIndexOf("Z") str.lastIndexOf str "Z" str.indexOf("A") str.indexOf str "A" 1 bw.flush() bw.flush bw String[] args args public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    }
} public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    }
} Main

import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String str = br.readLine();
        System.out.println(str.lastIndexOf("Z") - str.indexOf("A") + 1);
        bw.flush();
    }
}
