import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);
		} {
			String s = scanner.next();
			System.out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) String s = scanner.next(); s scanner.next() scanner.next scanner 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 String[] args args public class Main {

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

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

public class Main {

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