import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    }
} Main public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    } main {
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S  = sc.next(); S sc.next() sc.next sc char[]ss = S.toCharArray(); ss S.toCharArray() S.toCharArray S int[]a = new int[S.length()]; a new int[S.length()] S.length() S.length S int[]z = new int[S.length()]; z new int[S.length()] S.length() S.length S for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    } int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    } {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    } if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	} ss[i] == 'A' ss[i] ss i 'A' {
    		a[i]++;
    	} a[i]++ a[i] a i if(ss[i] == 'Z'){
    		z[i]++;
    	} ss[i] == 'Z' ss[i] ss i 'Z' {
    		z[i]++;
    	} z[i]++ z[i] z i int A = 0 A 0 Z = 0; Z 0 for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    } int i=S.length()-1; int i=S.length()-1; i S.length()-1 S.length() S.length S 1 i>=0 i 0 i-- i-- i {
    	if(a[i] == 1) {
    		A = i;
    	}
    } {
    	if(a[i] == 1) {
    		A = i;
    	}
    } if(a[i] == 1) {
    		A = i;
    	} a[i] == 1 a[i] a i 1 {
    		A = i;
    	} A = i A i for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	} int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	} {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	} if(z[i] == 1) {
        		Z = i ;
        	} z[i] == 1 z[i] z i 1 {
        		Z = i ;
        	} Z = i Z i System.out.println(Z-A+1) System.out.println System.out System System.out Z-A+1 Z-A Z A 1 String[] args args public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    }
} public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S  = sc.next();
    char[]ss = S.toCharArray();
    int[]a = new int[S.length()];
    int[]z = new int[S.length()];
    
    for(int i=0; i<S.length(); i++) {
    	if(ss[i] == 'A') {
    		a[i]++;
    	}else if(ss[i] == 'Z'){
    		z[i]++;
    	}
    }
    int A = 0, Z = 0;
    for(int i=S.length()-1; i>=0; i--) {
    	if(a[i] == 1) {
    		A = i;
    	}
    }
    	for(int i=0; i<S.length(); i++) {
        	if(z[i] == 1) {
        		Z = i ;
        	}
    	}
        	System.out.println(Z-A+1);
    }
}
