import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  }
} import java.util.*; util.* java public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  }
} Main public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  } main {
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String S = scan.next(); S scan.next() scan.next scan boolean isBetween = false; isBetween false int topA = 0; topA 0 int bottomZ = 0; bottomZ 0 int cnt = 0; cnt 0 int i = 0; i 0 for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        } i = 0 ; i = 0 i 0 i++ i++ i {
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        } {
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        } if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          } S.substring(i,i+1).charAt(0) == 'A' S.substring(i,i+1).charAt(0) S.substring(i,i+1).charAt S.substring(i,i+1) S.substring S i i+1 i 1 0 'A' {
            topA = i;
            break;
          } topA = i topA i break; for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        } i = S.length() ; i = S.length() i S.length() S.length S i-- i-- i {
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        } {
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        } if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          } S.substring(i-1,i).charAt(0) == 'Z' S.substring(i-1,i).charAt(0) S.substring(i-1,i).charAt S.substring(i-1,i) S.substring S i-1 i 1 i 0 'Z' {
            bottomZ = i-1;
            break;
          } bottomZ = i-1 bottomZ i-1 i 1 break; cnt = bottomZ - topA + 1 cnt bottomZ - topA + 1 bottomZ - topA bottomZ topA 1 System.out.println(cnt) System.out.println System.out System System.out cnt String args[] args public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  }
} public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  }
} Main
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        
        String S = scan.next();
        
        boolean isBetween = false;
        int topA = 0;
        int bottomZ = 0;
        int cnt = 0;
        
        int i = 0;
        
        for(i = 0 ; ; i++){
          if(S.substring(i,i+1).charAt(0) == 'A'){
            topA = i;
            break;
          }
        }
        
        for(i = S.length() ; ; i--){
          if(S.substring(i-1,i).charAt(0) == 'Z'){
            bottomZ = i-1;
            break;
          }
        }
        
        /* //MLE, TLEが起きる愚直なやり方
        int i = 0;//for iの代り
        
        String[] strArray = S.split("");
		for(String s_one : strArray) {
          
          i++;
          
		  if(s_one.charAt(0) == 'A' && isBetween == false){
            isBetween = true;
            count++;
          }
          else if(isBetween == true){
            count++;
          }
          
          if(s_one.charAt(0) == 'Z' && isBetween == true && S.substring(i, S.length() ).contains("Z") == false  ){
            isBetween = false;
            if(cnt < count)cnt = count;
            count = 0;
          }
		}
        */
        
        cnt = bottomZ - topA + 1;
        
        System.out.println(cnt);
	  }
}