import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	}
} Main public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	} main {
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	} Scanner cin = new Scanner(System.in); cin new Scanner(System.in) String target = cin.next(); target cin.next() cin.next cin cin.close() cin.close cin int position_a=target.length(); position_a target.length() target.length target int position_z=0; position_z 0 for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		} int i=0; int i=0; i 0 i<target.length() i target.length() target.length target i++ i++ i {
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		} {
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		} if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			} target.charAt(i)=='A' target.charAt(i) target.charAt target i 'A' {
				if(i<position_a){
					position_a=i;
				}
			} if(i<position_a){
					position_a=i;
				} i<position_a i position_a {
					position_a=i;
				} position_a=i position_a i if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			} target.charAt(i)=='Z' target.charAt(i) target.charAt target i 'Z' {
				if(position_z<i){
					position_z=i;
				}
			} if(position_z<i){
					position_z=i;
				} position_z<i position_z i {
					position_z=i;
				} position_z=i position_z i System.out.println(position_z-position_a+1) System.out.println System.out System System.out position_z-position_a+1 position_z-position_a position_z position_a 1 String args[] args public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	}
} public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String target = cin.next();
		cin.close();
		int position_a=target.length();
		int position_z=0;

		for(int i=0;i<target.length();i++){
			if(target.charAt(i)=='A'){
				if(i<position_a){
					position_a=i;
				}
			}else if(target.charAt(i)=='Z'){
				if(position_z<i){
					position_z=i;
				}
			}
		}

		System.out.println(position_z-position_a+1);
	}
}
