import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        StringTokenizer st = new StringTokenizer(br.readLine());

        String s = br.readLine();

        int a = s.indexOf("A");
        int z = s.lastIndexOf("Z");

        System.out.println(z-a+1);

    }


} import java.io.*; io.* java import java.util.*; util.* java class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        StringTokenizer st = new StringTokenizer(br.readLine());

        String s = br.readLine();

        int a = s.indexOf("A");
        int z = s.lastIndexOf("Z");

        System.out.println(z-a+1);

    }


} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        StringTokenizer st = new StringTokenizer(br.readLine());

        String s = br.readLine();

        int a = s.indexOf("A");
        int z = s.lastIndexOf("Z");

        System.out.println(z-a+1);

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        StringTokenizer st = new StringTokenizer(br.readLine());

        String s = br.readLine();

        int a = s.indexOf("A");
        int z = s.lastIndexOf("Z");

        System.out.println(z-a+1);

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s = br.readLine(); s br.readLine() br.readLine br int a = s.indexOf("A"); a s.indexOf("A") s.indexOf s "A" int z = s.lastIndexOf("Z"); z s.lastIndexOf("Z") s.lastIndexOf s "Z" 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
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        StringTokenizer st = new StringTokenizer(br.readLine());

        String s = br.readLine();

        int a = s.indexOf("A");
        int z = s.lastIndexOf("Z");

        System.out.println(z-a+1);

    }


}
