
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc 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' int result = z - a + 1; result z - a + 1 z - a z a 1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = s.indexOf('A');
		int z = s.lastIndexOf('Z');
		int result = z - a + 1;
		System.out.println(result);
	}
} Main

import java.util.*;

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