#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	char *s = malloc(sizeof(char)*200005);
	int *a = malloc(sizeof(int)), count = 0;
	*a = 0;
	scanf("%s", s); 
	for (int i=0; i<strlen(s); ++i) {
	    if (*a == 1 || s[i]=='A') {
	        if (s[i]=='Z') {
	            ++count;
	            break;
	        }
	        *a=1;
	        ++count;
	    }
	}
	printf("%d\n", count);
	free(s);
	free(a);
	return 0;
}