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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+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 input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	} main {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	} BufferedReader input =new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) String str = input.readLine( ); str input.readLine( ) input.readLine input int x = str.indexOf("A"); x str.indexOf("A") str.indexOf str "A" int y = str.lastIndexOf("Z"); y str.lastIndexOf("Z") str.lastIndexOf str "Z" System.out.println(y-x+1) System.out.println System.out System System.out y-x+1 y-x y x 1 String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+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 input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	}

}
