import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	}
} import java.io.File; File java.io import java.io.FileInputStream; FileInputStream java.io import java.util.NoSuchElementException; NoSuchElementException java.util import java.util.Scanner; Scanner java.util import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.Deque; Deque java.util import java.util.HashMap; HashMap java.util import java.util.List; List java.util import java.util.Map.Entry; Entry java.util.Map public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	}
} Main public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	} main {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A')) System.out.println System.out System System.out 1 + s.lastIndexOf('Z') - s.indexOf('A') 1 + s.lastIndexOf('Z') 1 s.lastIndexOf('Z') s.lastIndexOf s 'Z' s.indexOf('A') s.indexOf s 'A' String[] args args public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	}
} public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	}
} Main
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

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