#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.length();
	int t=0;
	while(s[t]!='A') t++;
	int end=l-1;
	while(s[end]!='Z') end--;
	cout<<end-t+1<<endl;
	return 0;
}