import java.util.*;

public class Main {

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

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    }
} import java.util.*; util.* java public class Main {

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

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] sArr = sc.next().toCharArray();

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    } main {
        Scanner sc = new Scanner(System.in);
        char[] sArr = sc.next().toCharArray();

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] sArr = sc.next().toCharArray(); sArr sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int indexA = sArr.length; indexA sArr.length sArr sArr.length int indexZ = 0; indexZ 0 for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        } int i = 0; int i = 0; i 0 i < sArr.length i sArr.length sArr sArr.length i++ i++ i {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        } {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        } switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            } sArr[i] sArr i case 'A': 'A' case 'A': if (indexA > i) indexA = i; indexA > i indexA i indexA = i indexA i break; case 'Z': 'Z' case 'Z': if (indexZ < i) indexZ = i; indexZ < i indexZ i indexZ = i indexZ i break; System.out.println(indexZ - indexA + 1) System.out.println System.out System System.out indexZ - indexA + 1 indexZ - indexA indexZ indexA 1 String[] args args public class Main {

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

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    }
} public class Main {

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

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    }
} Main
import java.util.*;

public class Main {

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

        int indexA = sArr.length;
        int indexZ = 0;
        for (int i = 0; i < sArr.length; i++) {
            switch (sArr[i]) {
                case 'A':
                    if (indexA > i) indexA = i;
                    break;
                case 'Z':
                    if (indexZ < i) indexZ = i;
                    break;
            }
        }


        System.out.println(indexZ - indexA + 1);

    }
}
