import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    }
} Main public static void main(String[] args){
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    } main {
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    } String s = new Scanner(System.in).next(); s new Scanner(System.in).next() new Scanner(System.in).next new Scanner(System.in) int b = s.indexOf('A'); b s.indexOf('A') s.indexOf s 'A' int e = s.lastIndexOf('Z'); e s.lastIndexOf('Z') s.lastIndexOf s 'Z' s = s.substring(b,e+1) s s.substring(b,e+1) s.substring s b e+1 e 1 System.out.println(s.length()) System.out.println System.out System System.out s.length() s.length s String[] args args public class Main{
    public static void main(String[] args){
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    }
} public class Main{
    public static void main(String[] args){
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        String s = new Scanner(System.in).next();
        int b = s.indexOf('A');
        int e = s.lastIndexOf('Z');
        s = s.substring(b,e+1);
        System.out.println(s.length());
    }
}