import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    } main {
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter ou = new PrintWriter(System.out); ou new PrintWriter(System.out) String s = sc.next(); s sc.next() sc.next sc sc.close() sc.close sc int a = 0; a 0 int z = s.length() - 1; z s.length() - 1 s.length() s.length s 1 boolean k = true; k true while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		} k {
			if(s.charAt(a) == 'A') break;
			a++;
		} if(s.charAt(a) == 'A') break; s.charAt(a) == 'A' s.charAt(a) s.charAt s a 'A' break; a++ a k = true k true while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		} k {
			if(s.charAt(z) == 'Z') break;
			z--;
		} if(s.charAt(z) == 'Z') break; s.charAt(z) == 'Z' s.charAt(z) s.charAt s z 'Z' break; z-- z ou.println(z - a + 1) ou.println ou z - a + 1 z - a z a 1 ou.flush() ou.flush ou String[] args args public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    }
} public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    }
} Main
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		sc.close();
		int a = 0;
		int z = s.length() - 1;
		boolean k = true;
		while(k){
			if(s.charAt(a) == 'A') break;
			a++;
		}
		k = true;
		while(k){
			if(s.charAt(z) == 'Z') break;
			z--;
		}
		ou.println(z - a + 1);
		ou.flush();
    }
}