
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    }
} Main private static Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args) {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    } main {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    } String s = scan.next(); s scan.next() scan.next scan int fromIndex = 0; fromIndex 0 for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	} {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	} if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    } s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
		fromIndex = i;
		break;
	    } fromIndex = i fromIndex i break; int toIndex = 0; toIndex 0 for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	} int i = s.length()-1; int i = s.length()-1; i s.length()-1 s.length() s.length s 1 i > -1 i -1 1 i-- i-- i {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	} {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	} if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
		toIndex = i;
		break;
	    } toIndex = i toIndex i break; System.out.println(toIndex - fromIndex + 1) System.out.println System.out System System.out toIndex - fromIndex + 1 toIndex - fromIndex toIndex fromIndex 1 scan.close() scan.close scan String[] args args public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    }
} public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    }
} Main

import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String s = scan.next();
	int fromIndex = 0;
	for (int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'A') {
		fromIndex = i;
		break;
	    }
	}
	int toIndex = 0;
	for (int i = s.length()-1; i > -1; i--) {
	    if(s.charAt(i) == 'Z') {
		toIndex = i;
		break;
	    }
	}

	System.out.println(toIndex - fromIndex + 1);
	scan.close();
    }
}
