import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int a = s.indexOf('A'); a s.indexOf('A') s.indexOf s 'A' int z = s.lastIndexOf('Z'); z s.lastIndexOf('Z') s.lastIndexOf s 'Z' int result = z - a + 1; result z - a + 1 z - a z a 1 System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    }
} Main
import java.util.*;
import java.lang.*;

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