import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.lastIndexOf('Z') - s.indexOf('A') + 1;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.lastIndexOf('Z') - s.indexOf('A') + 1;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

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

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.lastIndexOf('Z') - s.indexOf('A') + 1;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.lastIndexOf('Z') - s.indexOf('A') + 1;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.lastIndexOf('Z') - s.indexOf('A') + 1;
    }
}