import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    } main {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan int a = 0; a 0 int z = 0; z 0 boolean ba = true; ba true boolean bb = true; bb true for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                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' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        } {
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        } if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            } s.charAt(i) == 'A' && ba s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' ba {
                a = i;
                ba = false;
            } a = i a i ba = false ba false if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            } s.charAt(s.length() - i - 1) == 'Z' && bb s.charAt(s.length() - i - 1) == 'Z' s.charAt(s.length() - i - 1) s.charAt s s.length() - i - 1 s.length() - i - 1 s.length() s.length s i 1 'Z' bb {
                z = s.length() - i - 1;
                bb = false;
            } z = s.length() - i - 1 z s.length() - i - 1 s.length() - i - 1 s.length() s.length s i 1 bb = false bb false if(!ba && !bb){
                break;
            } !ba && !bb !ba ba !bb bb {
                break;
            } break; 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 scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    }
} public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int z = 0;
        boolean ba = true;
        boolean bb = true;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'A' && ba){
                a = i;
                ba = false;
            }
            if(s.charAt(s.length() - i - 1) == 'Z' && bb){
                z = s.length() - i - 1;
                bb = false;
            }
            if(!ba && !bb){
                break;
            }
        }
        System.out.println(z - a + 1);
    }
}