import java.util.*;

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

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String cha = sc.next();

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String cha = sc.next();

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
        String cha = sc.next();

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

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

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String cha = sc.next();

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	}
} Main
import java.util.*;

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

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	}
}