
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

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");
		
		System.out.println(z - a + 1);
		
	}
} import java.math.BigDecimal; BigDecimal java.math import java.math.BigInteger; BigInteger java.math 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();
		
		int a = s.indexOf("A");
		int z = s.lastIndexOf("Z");
		
		System.out.println(z - a + 1);
		
	}
} 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");
		
		System.out.println(z - a + 1);
		
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int a = s.indexOf("A");
		int z = s.lastIndexOf("Z");
		
		System.out.println(z - a + 1);
		
	} 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" System.out.println(z - a + 1) System.out.println System.out System System.out z - a + 1 z - a z a 1 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");
		
		System.out.println(z - a + 1);
		
	}
} 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");
		
		System.out.println(z - a + 1);
		
	}
} Main

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

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");
		
		System.out.println(z - a + 1);
		
	}
}