#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
	int z;
	string s;
	cin >> s;

	cout << (int)s.rfind("Z")-(int)s.find("A")+1 << endl;
	return 0;
}