import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int positionA = Integer.MAX_VALUE; positionA Integer.MAX_VALUE Integer Integer.MAX_VALUE int positionZ = 0; positionZ 0 for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        } 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') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        } {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        } if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            } s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' {
                if (positionA > i) positionA = i;
            } if (positionA > i) positionA = i; positionA > i positionA i positionA = i positionA i if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
                if (positionZ < i) positionZ = i;
            } if (positionZ < i) positionZ = i; positionZ < i positionZ i positionZ = i positionZ i System.out.println(positionZ-positionA+1) System.out.println System.out System System.out positionZ-positionA+1 positionZ-positionA positionZ positionA 1 String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    }
}
