stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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';}}}

// Optimized solution to the same problem (faster):
#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);

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}

// Optimized solution to the same problem (faster):
#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);

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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);

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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";

}


// Optimized solution to the same problem (faster):
#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);

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<cmath>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;

int main()

{

    string s;

    cin>>s;

    int a, z;

    int len = s.size();

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

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

            a = i;

            break;

        }

    }

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

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

            z = i;

            break;

        }

    }

    int ans = z-a+1;

    if(ans < 0)ans = 0;

    cout<<ans;





    return 0;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include<string>

using namespace std;

int main(void){

    // Your code here!

    string s;

    cin>>s;

    

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

    

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

int main(void)

{

	char s[200001];

	int a,z,i;

	scanf("%s",s);

	for(i=0; i<strlen(s); i++){

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

			a=i;

			break;

		}

	}

	for(i=strlen(s)-1; i>=0; i--){

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

			z=i;

			break;

		}

	}

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(void){

	string s;

	int i,j;

	int x,y;

	cin>>s;

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

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

			x=i;

			break;

		}

	}

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

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

			y=i;

			break;

		}

	}

	int cnt=0;

	for(i=x;i<=y;i++)	cnt++;

	cout<<cnt<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;

int main(void){

	char s[200000];

	int i;

	int n;

	int x,y;

	scanf("%s",s);

	n=strlen(s);

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

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

			x=i;

			break;

		}

	}

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

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

			y=i;

			break;

		}

	}

	y=n-y;

	x=x-1;

	printf("%d\n",n-(x+y));

	return 0;

}

	

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;







int main () {

	string s;

	cin >> s;

	int b = 0, e = s.length()-1;

	while (s[b] != 'A') b ++;

	while (s[e] != 'Z') e --;

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

	

	return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>



using namespace std;



int main() {

	string in;

	cin >> in;



	int i = 0;

	int j = in.size() - 1;

	while(in[i] != 'A') {

		i++;

	}

	while(in[j] != 'Z') {

		j--;

	}



	cout << (j - i + 1) << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>



using namespace std;



int main()

{

    string s;

    cin >> s;

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

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

#define INF 1<<30

#define LINF 1LL<<60



int main(void) {

    cin.tie(0); ios::sync_with_stdio(false);

    string s; cin >> s;

    int x = s.find('A');

    int y = s.rfind('Z');

    cout << y - x + 1 << endl;

    

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

using namespace std;

int main()

{

    int c1,c2;

    string s;

    cin>>s;

    int l=s.length();

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

    {

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

        {

            c1=i+1;

            break;

        }

    }

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

    {

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

        {

            c2=i+1;

        }

    }

    cout<<c2-c1+1<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

string s;

cin>>s;

int a,b;

a=s.find("A");

b=s.rfind("Z");

cout<<b-a+1;	

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define infi            5e9

#define infl            5e18

#define MX              100005

#define pi              2*acos(0.0)

#define ll              long long int

#define rr              read()

#define ff              first

#define ss              second

#define pb              push_back

#define pii             pair<int,int>

#define ms(a,b)         memset(a, b, sizeof(a))

#define loop(i,n)       for(register int i=0;i<n;i++)

#define pool(i,n)       for(register int i=n-1;i>=0;i--)

#define loop1(i,n)      for(register int i=1;i<=n;i++)

#define pool1(i,n)      for(register int i=n;i>0;i--)



using namespace std;



inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}

inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}

// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}

// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}



// //*************************************  Bitmask Opereations  **********************************//

// int Set(int N,int pos){return N=N | (1<<pos);}

// int reset(int N,int pos){return N= N & ~(1<<pos);}

// bool check(int N,int pos){return (bool)(N & (1<<pos));}

// //********************************************************************************************//





int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);

    //#ifdef rid.dle

    //freopen("in.txt", "r", stdin);//#endif

    

    string str;

    cin >> str;



    int n=str.length();



    int cur=-1,ans=-1;

    loop(i,n){

        if(str[i]=='A' && cur==-1)cur=1;

        else if(cur!=-1)cur++;

        if(str[i]=='Z' && cur!=-1)ans=cur;

    }

    cout << ans << endl;



    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main(){

int X=0,M=0,U=0,T=0;

string N;

cin>>N;

int len=N.length();

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

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

	X=i;

	T=1;

}

if(T==1)

break;

}

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

	

	if(N[y]=='Z'){

		

		M=y;

		U=1;

	}

	if(U==1)

	break;

}

cout<<M-X+1;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main(){

string s;

cin>>s;

if(s.find("A")<s.rfind("Z"))

{

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

}

else

cout<<0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

int max=0,counter=0,m;

string s;

cin>>s;

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

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

		m=i;

		if(counter>0)

		break;

	

	for(m;m<s.length();m++){

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

			counter++;

			if(counter>max){

				max=counter;

			    

			}	

		}

		else

		counter++;

		

	}

	

   

}

}

cout<<max;

return 0;

} 


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

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";

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{

  string s;

 int x,y,sum=0;

  cin>>s;

x=s.find("A");

y=s.rfind("Z");

for(int i=x;i<=y;i++)

{

	sum++;

}

cout<<sum;

 return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

char a[200005];



int main(){



	scanf("%s",a);

	string s1 (a);

	

int n=s1.find("A");

int y=s1.rfind("Z");

cout<<(y-n+1);

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main(){

	long long sum = 0,Z = 0,z;

	string s; cin >> s;

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

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

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

			break;

		}

		sum++;

	}

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

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

			break;

		}

		Z++;

	}

	cout << m - (sum + Z);

	return 0;

}




// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int MAXN = 2e5 + 10;



char s[MAXN];



int main() {

  int i, j;



  scanf(" %s", s);



  i = 0;

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

  

  j = strlen(s);

  while (s[j] != 'Z') --j;



  printf("%d\n", j - i + 1);

  return 0;

}

// Fastest known solution for this problem: