import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
}} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
}} Main public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
} main {
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
} Scanner sc = new Scanner(in); sc new Scanner(in) String s=sc.next(); s sc.next() sc.next sc int l=0 l 0 r=0; r 0 for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=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'){l=i;break;}
    } {
        if(s.charAt(i)=='A'){l=i;break;}
    } if(s.charAt(i)=='A'){l=i;break;} s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {l=i;break;} l=i l i break; for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    } 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(s.charAt(i)=='Z'){r=i+1;break;}
    } {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    } if(s.charAt(i)=='Z'){r=i+1;break;} s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {r=i+1;break;} r=i+1 r i+1 i 1 break; out.println(s.substring(l,r).length()) out.println out s.substring(l,r).length() s.substring(l,r).length s.substring(l,r) s.substring s l r String[] args args public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
}} public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
}} Main
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
}}