import java.util.Scanner;

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

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

      	sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

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

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

      	sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

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

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

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

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

      	sc.close();
	}
} Main
import java.util.Scanner;

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

		String s = sc.next();

		System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);

      	sc.close();
	}
}