import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s = br.readLine(); s br.readLine() br.readLine br int a = 0; a 0 int z = 0; z 0 while (s.charAt(a) != 'A') {
            a++;
        } s.charAt(a) != 'A' s.charAt(a) s.charAt s a 'A' {
            a++;
        } a++ a for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        } int i = a + 1; int i = a + 1; i a + 1 a 1 i < s.length() i s.length() s.length s i++ i++ i {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        } {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        } if (s.charAt(i) == 'Z') {
                z = i;
            } s.charAt(i) == 'Z' s.charAt(i) s.charAt s i 'Z' {
                z = i;
            } z = i z i System.out.println(z-a+1) System.out.println System.out System System.out z-a+1 z-a z a 1 String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    }
}
