import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    }
} import java.nio.file.*; file.* java.nio import java.nio.charset.*; charset.* java.nio import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    } main {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int start = 0 start 0 end=0; end 0 char s[] = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i<s.length i s.length s s.length i++ i++ i {
            if(s[i]=='A'){
                start = i;
                break;
            }
        } {
            if(s[i]=='A'){
                start = i;
                break;
            }
        } if(s[i]=='A'){
                start = i;
                break;
            } s[i]=='A' s[i] s i 'A' {
                start = i;
                break;
            } start = i start i break; for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        } int i = s.length-1; int i = s.length-1; i s.length-1 s.length s s.length 1 0<=i 0 i i-- i-- i {
            if(s[i]=='Z'){
                end = i;
                break;
            }
        } {
            if(s[i]=='Z'){
                end = i;
                break;
            }
        } if(s[i]=='Z'){
                end = i;
                break;
            } s[i]=='Z' s[i] s i 'Z' {
                end = i;
                break;
            } end = i end i break; System.out.println(end-start+1) System.out.println System.out System System.out end-start+1 end-start end start 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    }
} Main
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    }
}
