import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 1);
    }
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 1);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 1);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 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 f = s.indexOf("A"); f s.indexOf("A") s.indexOf s "A" int e = s.lastIndexOf("Z"); e s.lastIndexOf("Z") s.lastIndexOf s "Z" System.out.println(e - f + 1) System.out.println System.out System System.out e - f + 1 e - f e f 1 String[] args args public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 1);
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 1);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int f = s.indexOf("A");
        int e = s.lastIndexOf("Z");
        System.out.println(e - f + 1);
    }
}

