
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	}
} Main public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	} main {
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	} Scanner sc= new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z")); line str.substring(str.indexOf("A"), str.lastIndexOf("Z")) str.substring str str.indexOf("A") str.indexOf str "A" str.lastIndexOf("Z") str.lastIndexOf str "Z" System.out.println(line.length()+1) System.out.println System.out System System.out line.length()+1 line.length() line.length line 1 String[] args args public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	}
} public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	}
} Main

import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	
	String str = sc.next();
	String line = str.substring(str.indexOf("A"), str.lastIndexOf("Z"));
	System.out.println(line.length()+1);
	
	}
}
