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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	}

}


 import java.io.*; io.* java import java.util.*; util.* java public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	}

} Main public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	} main {
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	} FastReader in = new FastReader(); in new FastReader() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) char[] s = in.next().toCharArray(); s in.next().toCharArray() in.next().toCharArray in.next() in.next in int start = -1; start -1 1 boolean done = false; done false int end = -1; end -1 1 for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		} int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		} {
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		} if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			} !done&&s[i] == 'A' !done done s[i] == 'A' s[i] s i 'A' {
				start = i;
				done = true;
			} start = i start i done = true done true if (s[i]=='Z'){
				end = i;
			} s[i]=='Z' s[i] s i 'Z' {
				end = i;
			} end = i end i int len = end - start +1; len end - start +1 end - start end start 1 out.println(len) out.println out len out.flush() out.flush out out.close() out.close out String[] args args static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} FastReader BufferedReader br; br StringTokenizer st; st public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		} FastReader {
			br = new BufferedReader(new InputStreamReader(System.in));
		} br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		} next {
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		} try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			} catch(Exception e){
				e.printStackTrace();
			} Exception e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			} while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				} st==null||!st.hasMoreElements() st==null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
					st = new StringTokenizer(br.readLine());
				} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt(){
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong(){
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble(){
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		} nextLine {
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		} String s = ""; s "" try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			} catch(Exception e){
				e.printStackTrace();
			} Exception e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				s = br.readLine();
			} s = br.readLine() s br.readLine() br.readLine br return s; s public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	}

} public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	}

} Main
import java.io.*;
import java.util.*;

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	}

}



