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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	}

} 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 str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	} main {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int currentHighestLength = 0; currentHighestLength 0 int counter = 0; counter 0 while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		} counter < str.length() counter str.length() str.length str {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		} int testLength = 1; testLength 1 int currentHighestTestLength = 0; currentHighestTestLength 0 if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			} str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength str.charAt(counter) == 'A' str.charAt(counter) str.charAt str counter 'A' str.length() - counter > currentHighestLength str.length() - counter str.length() str.length str counter currentHighestLength {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				} counter + testLength < str.length() counter + testLength counter testLength str.length() str.length str {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				} if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					} str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength str.charAt(counter + testLength) == 'Z' str.charAt(counter + testLength) str.charAt str counter + testLength counter testLength 'Z' testLength + 1 > currentHighestLength testLength + 1 testLength 1 currentHighestLength {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} currentHighestTestLength = testLength + 1 currentHighestTestLength testLength + 1 testLength 1 testLength++ testLength {
						testLength++;
					} testLength++ testLength counter = str.length() counter str.length() str.length str {
				counter++;
			} counter++ counter if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			} currentHighestTestLength > currentHighestLength currentHighestTestLength currentHighestLength {
				currentHighestLength = currentHighestTestLength;
			} currentHighestLength = currentHighestTestLength currentHighestLength currentHighestTestLength {
			} System.out.println(currentHighestLength) System.out.println System.out System System.out currentHighestLength String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	}

}
