
import java.io.*;
import java.util.*;


	public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		}
		}
	 import java.io.*; io.* java import java.util.*; util.* java public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		}
		} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		} main {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x = sc.next(); x sc.next() sc.next sc int aposition = x.indexOf("A"); aposition x.indexOf("A") x.indexOf x "A" int zposition=x.lastIndexOf("Z"); zposition x.lastIndexOf("Z") x.lastIndexOf x "Z" int total = zposition-aposition +1; total zposition-aposition +1 zposition-aposition zposition aposition 1 System.out.print(total) System.out.print System.out System System.out total String[] args args public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		}
		} public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		}
		} Main

import java.io.*;
import java.util.*;


	public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int aposition = x.indexOf("A");
		int zposition=x.lastIndexOf("Z");
		int total = zposition-aposition +1;
		System.out.print(total);
		}
		}
	
