import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    }

} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    }

} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    } main {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String k = sc.next(); k sc.next() sc.next sc System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1) System.out.println System.out System System.out k.lastIndexOf('Z') - k.indexOf('A') + 1 k.lastIndexOf('Z') - k.indexOf('A') k.lastIndexOf('Z') k.lastIndexOf k 'Z' k.indexOf('A') k.indexOf k 'A' 1 String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    }

} public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    }

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String k = sc.next();
        System.out.println(k.lastIndexOf('Z') - k.indexOf('A') + 1);

    }

}