import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    }
} Main public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    } main {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    } try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        } {
            solve(sc);
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) solve(sc) solve sc String[] args args public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    } solve {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    } String s = sc.next(); s sc.next() sc.next sc int firstA = s.indexOf('A'); firstA s.indexOf('A') s.indexOf s 'A' int lastZ = s.lastIndexOf('Z'); lastZ s.lastIndexOf('Z') s.lastIndexOf s 'Z' System.out.println(lastZ - firstA + 1) System.out.println System.out System System.out lastZ - firstA + 1 lastZ - firstA lastZ firstA 1 Scanner sc sc public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    }
}