stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>  

#include<iostream>  

#include<algorithm>  

#include<cstdlib>  

#include<cstring>

#include<string>

#include<climits>

#include<vector>

#include<cmath>

#define LL long long



using namespace std;



inline char nc(){

  static char buf[100000],*p1=buf,*p2=buf;

  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }

  return *p1++;

}



inline void read(int &x){

  char c=nc(),b=1;

  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;

  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;

}



inline void read(LL &x){

  char c=nc(),b=1;

  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;

  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;

}



int wt,ss[19];

inline void print(int x){

	if (x<0) x=-x,putchar('-'); 

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}

inline void print(LL x){

	if (x<0) x=-x,putchar('-');

	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}

}



int main()

{

    string s;

	cin>>s;

    int a,z;

    for (int i=0;i<s.size();i++)

        if (s[i]=='A') {a=i;break;}

    for(int i=s.size()-1;i>=0;i--)

        if (s[i]=='Z') {z=i;break;}

    cout<<z-a+1<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.337505951209549x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<iostream>

#include<stdlib.h>

#include<ctime>

#include<string>

#include<cmath>

#include<algorithm>

#include<vector>

#include<set>

#include<map>

#include<queue>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define LL long long

#define FOR(i,a,b) for (int i=a;i<=b;i++)

#define FORD(i,a,b) for (int i=a;i>=b;i--)

using namespace std;

typedef pair<int,int> pa;

void getint(int &v){

    char ch,fu=0;

    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());

    if(ch=='-') fu=1, ch=getchar();

    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';

    if(fu) v=-v;

}

char a[2333333];

int n,p,q;

int main(){

	scanf("%s",a+1);

	n=strlen(a+1);

	FOR(i,1,n)

		if (a[i]=='A'){

			p=i;

			break;

		}

	FORD(i,n,1)

		if (a[i]=='Z'){

			q=i;

			break;

		}

	printf("%d\n",q-p+1);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.255064733068243x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <set>

#include <map>

#include <queue>

#include <ctime>

#include <cmath>

#include <cstdio>

#include <vector>

#include <string>

#include <cctype>

#include <bitset>

#include <cstring>

#include <cstdlib>

#include <utility>

#include <iostream>

#include <algorithm>

#define REP(i,a,b) for(int i=(a);i<=(b);i++)

#define PER(i,a,b) for(int i=(a);i>=(b);i--)

#define RVC(i,S) for(int i=0;i<(S).size();i++)

#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)

using namespace std;

typedef long long LL;

typedef pair<int,int> pii;

     

template<class T> inline

void read(T& num) {

    bool start=false,neg=false;

    char c;

    num=0;

    while((c=getchar())!=EOF) {

        if(c=='-') start=neg=true;

        else if(c>='0' && c<='9') {

            start=true;

            num=num*10+c-'0';

        } else if(start) break;

    }

    if(neg) num=-num;

}

/*============ Header Template ============*/



const int maxn=(int)(2e5)+5;

char s[maxn];



int main() {

    scanf("%s",s+1);

    int n=strlen(s+1);

    int lst=n+1,res=0;

    REP(i,1,n) if(s[i]=='A') lst=min(lst,i); else if(s[i]=='Z') res=max(res,i-lst+1);

    printf("%d\n",res);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.215447816115771x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



char s[200010];



int main()

{

    int a, b;



    scanf("%s", s);

    int x = strlen(s);

    for (int i = 0; i < x; i++) {

        if (s[i] == 'A') {

            a = i;

            break;

        }

    }

    for (int i = x - 1; i >= 0; i--) {

        if (s[i] == 'Z') {

            b = i;

            break;

        }

    }

    printf("%d\n", b - a + 1);

}


// Faster C++ solution for the same problem (measured speedup: 5.218133415812042x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long int LLI;





int main() { 

    string str;

    while (cin >> str) {

        int n =str.length();

        int st = n, en = 0;

        for (int i = 0; i < n; ++i) {

            if (str[i] == 'A') st = min(st, i);

            if (str[i] == 'Z') en = i;

        }

        cout << en-st+1 << "\n";

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.294755000650774x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);

  string s; cin >> s;

  int a = 0;

  for (int i = 0; i < (int)s.size(); i++) {

    a = i;

    if (s[i] == 'A') break;

  }

  int n = (int)s.size();

  int z = n - 1;

  for (int i = n - 1; i >= 0; i--) {

    z = i;

    if (s[i] == 'Z') break;

  }

  cout << z - a + 1 << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.404128480508719x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <cstdio>

#include <cmath>



#include <iostream>

#include <vector>

#include <string>



using namespace std;



int main(int argc, char const *argv[]) {

	string str;



	cin >> str;



	cout << str.rfind('Z') - str.find('A') + 1 << endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2993514126904895x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <iostream>

#include <string>

using namespace std;



int main(){

	string s;

	cin >> s;

	int l = -1, r = -1;

	for(int i = 0; i < s.size(); i++)

		if(s[i] == 'A'){

			l = i;

			break;

		}

	for(int i = s.size()-1; i >= 0; i--)

		if(s[i] == 'Z'){

			r = i;

			break;

		}

	if(l == -1 || r == -1 || r < l)

		cout << 0 << endl;

	else

		cout << r - l + 1 << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.296341065873357x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <vector>



using namespace std;



int main()

{

    string s;

    cin >> s;



    int pos = 0;

    int num = 0;



    for (int i = 0; i < s.size(); i++){

        if (s[i] == 65){

            pos = i;

            break;

        }

    }



    int num2 = 0;



    for (int i = pos; i < s.size(); i++){

        num++;

        if (s[i] == 90){

            if (num > num2){

                num2 = num;

            }

        }

    }



    cout << num2 << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3378346643819174x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int  main(){

    string s;

    //int flat=1;

    //for(int i=0; i<s.size(); i++)

    cin>>s;

    cout<<s.rfind('Z')-s.find('A')+1<<endl;

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2993514126904895x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main(){

	string s;

	cin>>s;

	int start=0,end=0;

	for(int i=0;i<s.length();i++){

		if(s[i]=='A') {

			start=i;

			break;

		}

	}

	for(int i=0;i<s.length();i++){

		if(s[i]=='Z') end=i;

	}

	cout<<end-start+1;

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 5.28646655003727x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<iostream>

#include<iomanip>

#include<cstdio>

#include<algorithm>

#include<math.h>

#include <string.h>

using namespace std;

int main(){

	int i,j,m,n,a,b;

	string s;

	while(cin>>s){

		n=s.length();

		for(i=0;i<n;i++){

			if(s[i]=='Z'){

				b=i;

			}

		}

		for(i=0;i<n;i++){

			if(s[i]=='A'){

				a=i;

				break;

			}

		}

		cout<<b-a+1<<endl;

	} 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3430137163972375x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

using namespace std;

char s[200001];

int main(){

	cin>>s;

	char *start,*end;

	end=strrchr(s,'Z');

	start=strchr(s,'A');

//	if(end==NULL||start==NULL){

//		cout<<"-1"<<endl;

//	}

//	else{

		cout<<end-start+1<<endl;

//	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.274619584584109x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

#include <iomanip>

#define ALL(x) (x).begin(), (x).end()

#define dll(x) scanf("%I64d",&x)

#define xll(x) printf("%I64d\n",x)

#define sz(a) int(a.size())

#define all(a) a.begin(), a.end()

#define rep(i,x,n) for(int i=x;i<n;i++)

#define repd(i,x,n) for(int i=x;i<=n;i++)

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MSC0(X) memset((X), '\0', sizeof((X)))

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define eps 1e-6

#define gg(x) getInt(&x)

#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}

inline void getInt(int* p);

const int maxn=1000010;

const int inf=0x3f3f3f3f;

/*** TEMPLATE CODE * * STARTS HERE ***/

string s;

int main()

{

	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);

	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);

	cin>>s;

	int len=s.length();

	int l;

	int r;	

	rep(i,0,len)

	{

		if(s[i]=='A')

		{

			l=i;

			break;

		}

	}

	rep(i,0,len)

	{

		if(s[i]=='Z')

		{

			r=i;

		}

	}

	cout<<r-l+1<<endl;

	

	

    return 0;

}



inline void getInt(int* p) {char ch;do {ch = getchar();} 

while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');

while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}

else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 

{*p = *p * 10 + ch - '0';}}}

// Faster C++ solution for the same problem (measured speedup: 5.297516666087633x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int st,e;

    string s;

    cin>>s;

    int l=s.length();

    for(int i=0;i<l;i++)

    {

        if(s[i]=='A')

        {

            st=i+1;

            break;

        }

    }

    for(int i=0;i<l;i++)

    {

        if(s[i]=='Z')

        {

            e=i+1;

        }

    }

    cout<<e-st+1<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.296284716668407x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int A=0,Z=0,c=0,m=0,n=0;

    string s;

    getline(cin,s);

        int b=s.length();

        for(int x=0;x<b;x++)

        {

            if(s[x]=='A')

            {

                 A=x+1;

                 m=1;

                break;

            }

            if(m)

                break;

        }

        for(int x=b-1;x>0;x--)

        {

            if(s[x]=='Z')

            {

            Z=x+1;

            n=1;

            break;

            }

            if(n)

                break;

        }

        c=Z-A+1;



    cout<<c;

}

// Faster C++ solution for the same problem (measured speedup: 5.312255394839334x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<cmath>

using namespace std;

int main(){

	int a=0,len,c=0,d=0;

	char s[200000];

	cin>>s;

	len=strlen(s);

	for(int i=0;i<len;i++){

		if(s[i]=='A'){

			d=i;

			break;

		}	

	}

		for(int i=len-1;i>0;i--){

		if(s[i]=='Z'){

			c=i;

			break;

		}

		

}

	a=c-d+1;

	cout <<abs(a);

}

// Faster C++ solution for the same problem (measured speedup: 5.3042604746832005x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int m,st,e;

    string s;

    cin>>s;

    int l=s.length();

    for(int i=0;i<l;i++)

    {

        if(s[i]=='A')

        {

            st=i+1;

            break;

        }

    }

    for(int i=0;i<l;i++)

    {

        if(s[i]=='Z')

        {

            e=i+1;

        }

    }

    m=e-st+1;

    cout<<m<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.337687010700834x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

	string s;

	int i=0,j=0,k=0;

	cin>>s;

	for(;s[i]!='A';++i){

		

	}

	for(j=s.length();s[j]!='Z';j--)

	{

	}

	j++;

	cout<<j-i<<"\n";

}


// Faster C++ solution for the same problem (measured speedup: 5.2976746684622595x):
#include<stdio.h>

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

        for(int i=0;i<n;i++)

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;

int main()

{

    string a;

	cin>>a;

	int l,r;

	for(int i=0;i<a.size();i++)

	{

		if(a[i]=='A')

		{

			l=i;

			break;

		} 		

	} 

	for(int i=a.size()-1;i>=0;i--)

	{

		if(a[i]=='Z')

		{

			r=i;

			break;

		}

	}

	cout<<r-l+1<<endl;	

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.754020097308721x):
#include <stdio.h>

#include <math.h>

#include <string.h>

int main(){

	char strk[1000001];

	bool bz=false;

	int sum=0,k=0;

	scanf("%s",strk);

	for(int i=0;i<=strlen(strk)-1;i++){

		if(strk[i]=='A')bz=true;

		if(bz==true)k++;

		if(strk[i]=='Z'&&bz==true){

			if(k>sum)sum=k;

		}

	}

	printf("%d\n",sum);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

    string s;

    cin >> s;

    int a = 0, z = 0;

    for(int i = 0; i < s.size(); i++) {

        if (s[i] == 'A') {

            a = i;

            break;

        }

    }

    for(int i = 0; i < s.size(); i++) {

        if (s[i] == 'Z') {

            z = i;

        }

    }

    string res = "";

    for(int i = a; i <= z; i++) {

        res += s[i];

    }

    cout << res.size() << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.333917055043006x):
#include<cstdio>

#include<algorithm>

using namespace std;

char str[200005];

int main(){



    scanf("%s",str);

    int ans = 0;

    int a=-1;

    for(int i=0;str[i];i++){

        if(str[i]=='Z'){

            if(a!=-1)

                ans = max(ans,i-a);

        }else if(str[i]=='A' && a==-1)

            a = i;

    }

    printf("%d\n",ans+1);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

    char temp=' ';

    string s,ans;

    cin >> s;

    bool check= false;

    int cnt=0;

    int cnt1=0;

    for(int i =0; i< s.size();i++){

        if(s[i]=='A') break;

        cnt++;

    }

    for(int i = s.size()-1; i >=0; i--){

        if(s[i]=='Z') break;

        cnt1++;

    }

    //cout << cnt << ' ' << cnt1 << ' ' << s.size() << endl;

    cout << (int)s.size()-(cnt+cnt1);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2854798412191295x):
#include<cstdio>

#include<algorithm>

using namespace std;

char str[200005];

int main(){



    scanf("%s",str);

    int ans = 0;

    int a=-1;

    for(int i=0;str[i];i++){

        if(str[i]=='Z'){

            if(a!=-1)

                ans = max(ans,i-a);

        }else if(str[i]=='A' && a==-1)

            a = i;

    }

    printf("%d\n",ans+1);

    return 0;

}