import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();

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

   int N = a.length;
   int start = 0;
   int end = a.length;
   for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   }
   for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   }
    System.out.println(end-start+1);
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();

   int N = a.length;
   int start = 0;
   int end = a.length;
   for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   }
   for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   }
    System.out.println(end-start+1);
 } main {
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();

   int N = a.length;
   int start = 0;
   int end = a.length;
   for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   }
   for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   }
    System.out.println(end-start+1);
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] a = sc.next().toCharArray(); a sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int N = a.length; N a.length a a.length int start = 0; start 0 int end = a.length; end a.length a a.length for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   } int i=0; int i=0; i 0 i<N i N i++ i++ i {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   } {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   } if(a[i]=='A')
     {
       start=i;
       break;
     } a[i]=='A' a[i] a i 'A' {
       start=i;
       break;
     } start=i start i break; for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   } int i=N-1; int i=N-1; i N-1 N 1 i>=0 i 0 i-- i-- i {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   } {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   } if(a[i]=='Z')
     {
       end=i;
       break;
     } a[i]=='Z' a[i] a i 'Z' {
       end=i;
       break;
     } end=i end i break; System.out.println(end-start+1) System.out.println System.out System System.out end-start+1 end-start end start 1 String[] args args public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();

   int N = a.length;
   int start = 0;
   int end = a.length;
   for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   }
   for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   }
    System.out.println(end-start+1);
 }
} public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();

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

   int N = a.length;
   int start = 0;
   int end = a.length;
   for(int i=0;i<N;i++) 
   {
     if(a[i]=='A')
     {
       start=i;
       break;
     }
   }
   for(int i=N-1;i>=0;i--) 
   {
     if(a[i]=='Z')
     {
       end=i;
       break;
     }
   }
    System.out.println(end-start+1);
 }
}