import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a=0 a 0 z=0; z 0 char A = 'A'; A 'A' char Z = 'Z'; Z 'Z' String s = sc.next(); s sc.next() sc.next sc char sa[] = s.toCharArray(); sa s.toCharArray() s.toCharArray s for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		} int i=0; int i=0; i 0 i<sa.length i sa.length sa sa.length i++ i++ i {
			if(sa[i]==A) {
				a=i;
				break;
			}
		} {
			if(sa[i]==A) {
				a=i;
				break;
			}
		} if(sa[i]==A) {
				a=i;
				break;
			} sa[i]==A sa[i] sa i A {
				a=i;
				break;
			} a=i a i break; for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		} int i=sa.length-1; int i=sa.length-1; i sa.length-1 sa.length sa sa.length 1 i>0 i 0 i-- i-- i {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		} {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		} if(sa[i]==Z) {
				z=i;
				break;
			} sa[i]==Z sa[i] sa i Z {
				z=i;
				break;
			} z=i z i break; System.out.print(z-a+1) System.out.print System.out System System.out z-a+1 z-a z a 1 sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	}
}
