Problem:


Score : 200 points

Problem Statement

Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s).

Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with A and ends with Z.

Constraints

1 ≦ |s| ≦ 200{,}000

s consists of uppercase English letters.

There exists a substring of s that starts with A and ends with Z.

Input

The input is given from Standard Input in the following format:

s

Output

Print the answer.

Sample Input 1

QWERTYASDFZXCV

Sample Output 1

5

By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.

Sample Input 2

ZABCZ

Sample Output 2

4

Sample Input 3

HASFJGHOGAKZZFEGA

Sample Output 3

12



Sample input:
QWERTYASDFZXCV


Sample output:
5

Submission status: Runtime Error

Solution code:
c = input()
s = []
for i in c:
    s.append(i)

list_a = []
list_z = []

while "a" in s:
    list_a.append(s.index("a"))
    s[s.index("a")] = "b"

while "z" in s:
    list_z.append(s.index("z"))
    s[s.index("z")] = "v"

answer = list_z[-1] - list_a[0] + 1
print(answer)

Submission status: Runtime Error

Solution code:
s = input()

posA = 0
posZ = 0

for i in range(len(s)):
  if s[i] == "A":
    posA = i
    break
for j in range(len(s)):
  if s[-j-1] == "Z":
    posZ = N - 1 - j
    break

print(posZ - posA + 1)

Submission status: Runtime Error

Solution code:
for i in range(len(s)):
    if s[i]=='A':
        a=i
        break
for j in reversed(range(len(s))):
    if s[j]=='Z':
        b=j
        break
print(b-a+1)

Submission status: Runtime Error

Solution code:
s=input()
a=False
for i,v in enumerate(s):
    if a==False:
        if v=="A":
            a=i
    else:
        if v=="Z":
            z=i
print(z-a+1)

Submission status: Runtime Error

Solution code:
s=input()
 
ds=list(s)
 
 
c1=0
while ds[c1]!='A'
  c1+=1
 
c2=-1
while ds[c2]!='Z':
  c2-=1
 
print(len(s[c1:c2]))

Submission status: Runtime Error

Solution code:
s=input()
 
ds=list(s)
 
 
c1=0
while ds[c1]!='A'
  c1+=1
 
c2=-1
while ds[c2]!='Z':
  c2-=1
 
print(s[c1:c2])
 
s=input()

ds=list(s)


c1=0
while ds[c1]!='A'
  c1+=1

c2=-1
while ds[c2]!='Z':
  c2-=1

print(len(s[c1:c2]))

Submission status: Runtime Error

Solution code:

s=input()

ds=list(s)


c1=0
while ds[c1]!='A'
  c1+=1

c2=-1
while ds[c2]!='Z':
  c2-=1

print(s[c1:c2])

Submission status: Runtime Error

Solution code:
s=input

a=s.find('A')
z=s.rfind('Z')

print(z-a)

Submission status: Runtime Error

Solution code:
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s),-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)

Submission status: Runtime Error

Solution code:
s=input()
a_min=0
z_max=0
for i in s:
  if s[i]=="A":
    a_min=i
    break
for i in s:
  if s[i]=="Z":
    z_max=i
print(z_max-a_min+1)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s;
	cin >> s;
	int f1, f2;
	rep(i,s.length()){
		if(s[i]=='A'){
			f1=i;
			break;
		}
	}
	rep(i,s.length()){
		if(s[i]=='Z') f2=i;
	}
	cout << f2-f1+1 << endl;
	return 0;
}

Submission status: Runtime Error

Solution code:
ZABCZ

Submission status: Runtime Error

Solution code:
s=list(input())

a=s.index("A")
for i in range(len(s),0):
  if s[i-1]=="Z":
    z=i-1
z-=len(s)-1
sum=z-a+1
print(sum)

Submission status: Runtime Error

Solution code:
s = input()
for i in range(len(s)):
  if s[i] == 'A':
    left = i
    break
    
for i in range(len(s)):
  if s[N-1-i] == 'Z':
    right = N-1-i
    break
    
print(right - left + 1)

Submission status: Runtime Error

Solution code:
s = input()
for i in range(N):
  if s[i] == 'A':
    left = i
    break
    
for i in range(N):
  if s[N-1-i] == 'Z':
    right = N-1-i
    
print(right - left + 1)

Submission status: Runtime Error

Solution code:
s = input()
i = 0
j = len(s) -1
t1 = 0
t2 = 0
while True:
  if(s[i] == "A"):
    t1 = i
  if(s[j] == "Z"):
    t2 = j
  if(t1 != 0 and t2 != 0):
    break
  
  i += 1
  j -= 1
print(t2-t1 +1)

Submission status: Runtime Error

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
a=input()
A=math.inf
Z=0
for i in range(len(a)):
    if(a[i]=='A'):
        A=min(A,i)
    elif(a[i]=='Z'):
        Z=i 
ans=Z-A+1
if(ans==-math.inf):
    print(0)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
a=input()
A=math.inf
Z=0
for i in range(len(a)):
    if(a[i]=='A'):
        A=min(A,i)
    elif(a[i]=='Z'):
        Z=i 
print(Z-A+1)

Submission status: Runtime Error

Solution code:
s = input()
print(s.rfond("Z") - s.find("A") + 1)

Submission status: Runtime Error

Solution code:
S = input()
a = -1
z = len(S)
for i, c in enumerate(input()):
  if c == "A" and a == -1: a = i
  if c == "Z": z = i

print(z-a+1)

Submission status: Runtime Error

Solution code:
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1):
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
    pos_z = i
      if pos_z - (pos_a -1) > length:
        length = pos_z - (pos_a -1)
      else:
        flag = 0

print(length)

Submission status: Runtime Error

Solution code:
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1)
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
      pos_z = i
      if pos_z - pos_a > length:
        length = pos_z - pos_a
      else:
        flag = 0

print(length)

Submission status: Runtime Error

Solution code:
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1)
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z':
    if flag == 1:
      pos_z = i
      if pos_z - pos_a > length:
        length = pos_z - pos_a
      else:
        flag = 0
        
print(length)

Submission status: Runtime Error

Solution code:
s = list(input())

flag = 0
pos_a, pos_z = 1
length = 0

for i, ltr in enumerate(s, 1)
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z':
    if flag == 1:
      pos_z = i
      if pos_z - pos_a > length:
        length = pos_z - pos_a
      else:
        flag = 0
        
print(length)

Submission status: Runtime Error

Solution code:
def resolve():
	s = input()
	a = float('inf')
	z = 0
	for i in s:
		if i == 'A':
			a = min(a, i)
		if i == 'Z':
			z = max(z, i)
	print(z - a + 1)
resolve()

Submission status: Runtime Error

Solution code:
l=len(s)
a=[]
z=[]
ans=0
for i in range(l):
    if s[i]=="A":
        a.append(i)
    elif s[i]=="Z":
        z.append(i)

for i in range(len(a)):
    for j in range(len(z)):
        if abs(z[j]-a[i]+1)>=ans:
            ans=abs(z[j]-a[i]+1)

Submission status: Runtime Error

Solution code:
s = input()
a = s.fin("A")
z = s. find("Z")
print(z - a + 1)

Submission status: Runtime Error

Solution code:
str.rfind()

Submission status: Runtime Error

Solution code:
s = list(input())
s1 = list(dropwhile(lambda x: x != 'A',s))
s2 = list(dropwhile(lambda x: x != 'Z',s1[::-1]))
print(len(s2))

Submission status: Runtime Error

Solution code:
s = input()
print(s.rfind(z)-s.find(a)+1)

Submission status: Runtime Error

Solution code:
s =input()
A=0
Z=0

for i in range(len(s)):
  s[i] =="A":
    A +=i+1
    break

    
for j in range(len(s)):
  s[-(j+1)] =="Z":
    Z +=len(s)-j
    break
    
print(Z-A+1)

Submission status: Runtime Error

Solution code:
s =input()
A=0
Z=0

for i in range(len(s)):
  s[i] =="A":
    A=i+1
    break

    
for j in range(len(s)):
  s[-(j+1)] =="Z":
    Z=len(s)-j
    break
    
print(Z-A+1)

Submission status: Runtime Error

Solution code:
s = list(input())
print(reversed(s).index("Z")-s.index("A")+1)

Submission status: Runtime Error

Solution code:
s = list(input())
print(s.reverse().index("Z")-s.index("A")+1)

Submission status: Runtime Error

Solution code:
s = list(input())
print(s.reverse.index("Z")-s.index("A")+1)

Submission status: Runtime Error

Solution code:
Not found

Submission status: Runtime Error

Solution code:
s=input()
x=1e9
for i in range(len(s)):
 if i=='A':x=min(x,i)
 if i=='Z':y=i
print(y-x+1)

Submission status: Runtime Error

Solution code:
import sys

s = input()
c = 0
C = 0

for i in range(len(s)):
    if s[i] == 'A':
        while(s[i] != 'Z'):
            c += 1
            i += 1
        if s[i] == 'Z':
            i += 1
            c += 1
            if s[i] == 'Z':
                c += 1
                break
    else:
        continue
    break
            
print(c)

Submission status: Runtime Error

Solution code:
s = input()
t = s[::-1]
a = s.index('a')
z = t.index('z')
print(len(s)-a-z)

Submission status: Runtime Error

Solution code:
s = input
t = s[::-1]
a = s.index('a')
z = t.index('z')
print(len(s)-a-z)

Submission status: Runtime Error

Solution code:
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    n=0
    a=100000000
    z=0
    for s in sss:
        if s=="A":
            a=min(a,n)
        elif s=="Z":
            z=n
        n+=1
    print(z-a+1)
    return


resolve()

Submission status: Runtime Error

Solution code:
S = list(input())
ans = []
for i in range(1, len(S)-1):
    if S[i]=="A":
        ans.append(i)
        break
T = S[::-1]
for i in range(len(T)):
    if T[i]=="Z":
        ans.append(i)
        break
print((len(S)-ans[0])-ans[1])

Submission status: Runtime Error

Solution code:
s=input()
ia=None
iz=None
for i,c in s:
  if ia==None and c=="a":
    ia=i
  if c=="z":
    iz=i
print(iz-ia+1)

Submission status: Runtime Error

Solution code:
s = input()
t = 0
u = 0
n = len(s)
for i in range(n):
  if s[i] == "A":
    t = i
    break
for j in range(n):
  if s[n-j] == "Z":
    u = n-j
print(u-t)

Submission status: Runtime Error

Solution code:
s=list(map(str,input()))
#print(s)
ans=0
for i in range(len(s)):
    if s[i]=='A':
        sa=i
    if s[i]=='Z':
        #print("VBHJ")
        ans=max(ans,i-sa+1)

print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  int min_a = s.size(), max_z = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'A' and i < min_a) {
      min_a = i;
    }
    if (s.at(i) == 'Z' and i > max_z) {
      max_z = i;
    }
  }
  cout << max_z - min_a + 1 << endl;
}

Submission status: Runtime Error

Solution code:
S = input()
list_A = []
list_Z = []
for i in range(len(S)):
  if s[i] == 'A':
    list_A.append(i)
  if s[i] == 'Z':
    list_Z.append(i)
a = list_A[0]
z = list_Z[-1]
print(z - a + 1)

Submission status: Runtime Error

Solution code:
s = list(input())
print(len(s[s.index("A"):s.index("Z",-1)]+1))

Submission status: Runtime Error

Solution code:
s=str(input())
a,b=s.find("A"),s,rfind("Z")
print(b-a+1)

Submission status: Runtime Error

Solution code:
s=input()
N=len(s)
f=s.index("a")
F=0
for i in range(N):
    if s[i]=="z":
        F==i
print(F-f+1)

Submission status: Runtime Error

Solution code:
s=input()
N=len(s)
f=s.index("a")
F=0
for i in range(N):
    if s[i]==z:
        F==i
print(F-f+1)

Submission status: Runtime Error

Solution code:
s=str(input())
L=len(s)
start=0
end=0
for i in range(L):
    if s[i] =="A":
        start = s.index(s[i])
        break
for k in range(L,0,-1):
    if s[k] =="Z":
        end = s.index(s[i])
        break
Ans=end-start+1
print(Ans)

Submission status: Runtime Error

Solution code:
s=input()
st=s.index('A')
t=s
t.reverse()
en=t.index('Z')
print(len(s)-st-en)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
s=input().strip()
for i in range(len(s)):
    if s[i]=="A":
        sa=i
for i in range(len(s)):
    if s[i]=="Z":
        sz=i
print(len(s[si:sz+1]))

Submission status: Runtime Error

Solution code:
m,n = map(int,input().split())
a = []*m
b = []*n
flag = False
for i in range(m):
    a.append(input())
for j in range(n):
    b.append(input())

for i in range(0, m-n):#比較開始を縦方向に動かす
    for j in range(0, m-n):#比較開始を横方向へ動かす
        for k in range(0,n):
            if b[k] != a[i][j:j+n]:
                break
            flag = True

if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S=input()
N=len(S)
for i in range(N):
  if S[i]=='A':
    A=i
    break
for i in range(N,0):
  if S[i]=='Z':
    Z=i
    break
ans=Z-A+1

print(ans)

Submission status: Runtime Error

Solution code:
S = list(input())
num_first = 0
num_last = 0
for i in range(len(S)):
    if S[i] == 'A':
        num_first = i
        break
for j in range(num_first, len(S)+1):
    if S[j] == 'Z':
        num_last = j
print(num_last - num_first + 1)

Submission status: Runtime Error

Solution code:
print(input().rfind("Z")-input().find("A")+1)

Submission status: Runtime Error

Solution code:
s = input()
print(s.rfind("Z") - s.fine("A") + 1)

Submission status: Runtime Error

Solution code:
s=input()
print(max(s.index("Z"))-min(s.index('A')))

Submission status: Runtime Error

Solution code:
s=input()
print(abs(min(s.index('A'))-max(s.index("Z"))))

Submission status: Runtime Error

Solution code:
s=input()
sento=0
matubi
for i in range(s):
  if s[i] == "A":
    sento=i
    break
for i in range(s):
  if s[i] == "Z" and i > sento:
    matubi=i
    break
print(s[sento+1:matubi+1])

Submission status: Runtime Error

Solution code:
s=input()
sento=0
matubi
for i in range(s):
  if s[i] == "A":
    sento=i
    break
for i in range(s):
  if s[i] == "Z" and i > sento:
    matubi=i
    break
print(s[sento:matubi+1])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

# input
s = input()

# solve
for f in range(len(s)):
    if s[i] == 'A':
        a = i
        break

for f in reversed(range(len(s))):
    if s[i] == 'Z':
        z = i
        break

# output
print(z - a + 1)

Submission status: Runtime Error

Solution code:
 s = str(input())
 

 for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break
 
 for i in reversed(range(len(s))):
    if s[i] == 'Z':
        z = i
        break
 

 print(z - a + 1)

Submission status: Runtime Error

Solution code:
s = input()

for i in range(len(s)):
    if s[i] == 'A':
        a_index = i

for j in range(-1, -(len(s)-a_index), -1):
    if s[j] == 'Z':
        z_index = j

length = (len(s) + z_index) - a_index + 1
print(length)

Submission status: Runtime Error

Solution code:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int first = -1, last = -2;
        for (int i = 0; i < input.length(); i++) {
            if(input.charAt(i) == 'A'){
                first = i;
                break;
            }
        }
        for(int i = input.length() - 1; i >= 0; i--){
            if(input.charAt(i) == 'Z'){
                last = i;
                break;
            }
        }
        System.out.println(last - first + 1);
    }
}

Submission status: Runtime Error

Solution code:
s=str(input())
S=int()
G=int()

#Sに最初のAのインデックスを取得
for i in range(len(s)):
  if s[i]=='A':
    S=s.index(s[i])
    break
    
ss=s[::-1]

#Gに最後のZのインデックスを取得
for j in range(len(ss)):
  if ss[j]=='Z':
    G=len(ss)-j-1
    break
print(G-S+1

Submission status: Runtime Error

Solution code:
s=str(input())
S=int()
G=int()

for i in range(len(s)):
  if s[i]=='a':
    S=s.index(s[i])
    break
for i in reversed(range(len(s))):
  if s[i]=='z':
    G=s.index(s[i])
    break
print(G-S+1

Submission status: Runtime Error

Solution code:
s=str(input())

for i in range(len(s)):
  if s[i]=='a':
    S=s.index(s[i])
    break
for j in reversed(range(len(s)):
  if s[j]=='z':
    G=s.index(s[j])
    break
print(G-S+1)

Submission status: Runtime Error

Solution code:
string = input()
ans=[]
for i in range(len(string)):
    if string[i] == 'A':
        ans.append(string[i])
        start=i
        break
for j in range(start+1,len(string)):
    if string[j]=='Z':
        ans.append(string[j])
        if string[j+1] not in 'Z':
            break
    else:
        ans.append(string[j])
print(len(ans))

Submission status: Runtime Error

Solution code:
s=input()
for i in len(s):
  if s[i] == 'A':
    a=i
    break
for i in len(s):
  if s[i] == 'Z':
    z=i
print(z-a+1)

Submission status: Runtime Error

Solution code:
s = list(input())
a_index = [i for i, x in enumerate(s) if x == 'A']
z_index = [i for i, x in enumerate(s) if x == 'Z']
distance = []

for i in a_index:
    for j in z_index:
        if i <= j:
            dis = j-i
            distance.append(dis)
        else:
            break

print(max(distance)+1)

Submission status: Runtime Error

Solution code:
s = list(input())
a_index = [i for i, x in enumerate(s) if x == 'A']
z_index = [i for i, x in enumerate(s) if x == 'Z']
distance = []

for i in a_index:
    for j in z_index:
        if i <= j:
            dis = abs(i-j)
            distance.append(dis)
        else:
            break

print(max(distance)+1)

Submission status: Runtime Error

Solution code:
s = list(input())
a_index = [i for i, x in enumerate(s) if x == 'A']
z_index = [i for i, x in enumerate(s) if x == 'Z']
distance = []

for i in a_index:
    for j in z_index:
        if i < j:
            dis = abs(i-j)
            distance.append(dis)
        else:
            break

print(max(distance)+1)

Submission status: Runtime Error

Solution code:
s=list(input())

a=0
for i in range(len(s)):
    if s[i]=='A':
        a=i
        break
b=0
for i in range(len(s)):
    if s[n-i-1]=='Z':
        b=n-i-1
        break
print(a-b+1)

Submission status: Runtime Error

Solution code:
s = input()
print(s.index("Z",-1)-s.index("A")+1)

Submission status: Runtime Error

Solution code:
s = input()
A= s.index('A')
for r in s[::-1]:
    Z = r.index('Z') 
print(s-Amin-Zmax+2)

Submission status: Runtime Error

Solution code:
s = input()
Amin = s.index('A')
for r in s[::-1]:
Zmax = r.index('Z') 
print(s-Amin-Zmax+2)

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
dif = 0
val=0
for i in range (l):
	if s[i] == 'A' and val==0:
			a = i	
			val=1
	if s[i] == 'Z':
		z = i
		dif = z-a
print(dif+1)

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
dif = 0
for i in range (l):
	if s[i] == 'A':
		a = i
	elif s[i] == 'Z':
		z = i
		dif = z-a
print(dif+1)

Submission status: Runtime Error

Solution code:
s=input()
print(len(s)-s.index('A')-s[:-1].index('Z'))

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end]))

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end+1]))

Submission status: Runtime Error

Solution code:
s = input()
print(len(s)-s[::-1].index("z")-s.index("a"))

Submission status: Runtime Error

Solution code:
s = input()
i = 0
while s[i] != 'A':
  i += 1
s.reverse()
j = 0
while s[j] != 'Z':
  j += 1
print(j-i+1)

Submission status: Runtime Error

Solution code:
s=input()
print(len(s)-s[::-1].index("z")-s.index("A"))

Submission status: Runtime Error

Solution code:
s=input()
print(len(s)-s[::-1].index("z")+s.index("A"))

Submission status: Runtime Error

Solution code:
s = input()
start = len(s)
end = 0

for i in range(s):
    if s[i] == "A":
        start = min(start,i)
    if s[len(s)-1-i] == "Z":
        end = max(end,i)

print(len(s)-start-end)

Submission status: Runtime Error

Solution code:
s = str(input())
print(len(s))
for i in range(len(s)):
    if s[i] == 'A':
        min = i
        break
for i in reversed(range(len(s))):
    if s[i] =='Z':
        max = i
        break

print(max)print(max-min+1)

Submission status: Runtime Error

Solution code:
S = input()
pos_a = -1
pos_z = -1
for i in range(len(S)):
  if S[i] == 'A' and pos_a < 0:
    pos_a = i
  if S[len(S)-i] == 'Z' and pos_z < 0:
    pos_z = len(S)-i
  if pos_a >= 0 and pos_z > 0:
    break
print(pos_z-pos_a+1)

Submission status: Runtime Error

Solution code:
S = input()
s = None//初期値
for i in range(len(S)):
  c = S[i]
  if c == "A":
    s = i
  if c == "Z":
    e = i
print(e-s+1)

Submission status: Runtime Error

Solution code:
S = input()
s = None//初期値
for i in range(len(S)):
  c = S[i]
  if c == "A" and s is None :
    s = i
  if c == "Z":
    e = i
print(e-s+1)

Submission status: Runtime Error

Solution code:
S = input()
for i in range(len(S)):
  c = S[i]
  if c == "A" and s is None :s = i
  if c == "Z":e = i
print(e-s+1)

Submission status: Runtime Error

Solution code:
S = input()
s = 0
for i in range(len(S)):
  c = S[i]
  s = i if c == "A" and s == 0
  if c == "Z":
    print(S[s:i+1])
    break

Submission status: Runtime Error

Solution code:
S = input()
s=0
for i in range(len(S)):
  c = S[i]
  s = i if c =="A" && s <> 0
  if c =="Z":
    print(S[s:i+1])
    break

Submission status: Runtime Error

Solution code:
S = input()
s=0
for i in len(S):
  c = S[i]
  s = i if c =="A" && s <> 0
  if c =="Z":
    print(S[s:i+1])
    break

Submission status: Runtime Error

Solution code:
S = input()
for i in len(S):
  c = S[i]
  s = i if c =='A'
  if c =='Z':
    print(S[s:i+1])
    break

Submission status: Runtime Error

Solution code:
s=list(input().split())

for i in range(len(s)):
  if i=='A':
    a=i
  if i=='Z':
    z=i
print(z-a+1)

Submission status: Runtime Error

Solution code:
s = list(input())
for num in s :
  if num == "A":
    index1 = s.index(num)
    continue
  if num == "Z":
    index2 = s.index(num)
    break
    
print(index2 - index1 + 1)

Submission status: Runtime Error

Solution code:
s = list(map(int, input().split())
int ans = 0;
for i in range(len(s)):
         if s[i] == "A":
            for i in range(len(s))
            	ans ++;
         	if s[i] == "Z":
         		out;
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return

#B
def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "A":
            a = min(a, num)
        if si == "Z":
            z = max(z, si)
    print(z-a+1)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return

#B
def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "a":
            a = min(a, num)
        if si == "z":
            z = max(z, si)
    print(z-a+1)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Runtime Error

Solution code:
for i in range(n):
    if s[i] == "A":
        ind_a = i
        break

for i in range(n):
    if s[i] == "Z":
        ind_z = i

print(ind_z - ind_a + 1)

Submission status: Runtime Error

Solution code:
first = s.find("A")
last = s.rfind("Z")
print(last - first+1)

Submission status: Runtime Error

Solution code:
s = input()
print(s.rindex('Z') - a.index('A') + 1)

Submission status: Runtime Error

Solution code:
def start(l):
    for i in range(1, l-1):
        if S_list[i] == "A":
            return i + 1


def finish(l):
    for i in range(1, l-1):
        if S_list[l - i] == "Z":
            return l - i + 1


S_list = list(input())
l = len(S_list)
print(finish(l) - start(l) + 1)

Submission status: Runtime Error

Solution code:
def start(l):
    for i in range(1, l):
        if S_list[i] == "A":
            return i


def finish(l):
    for i in range(1, l):
        if S_list[l - i] == "Z":
            return l - i


S_list = list(input())
l = len(S_list)
start(l)
finish(l)
print(finish(l) - start(l) + 1)

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
cntflg = False
endflg = False
for i in s:
        if i == 'Z' and cntflg:
                cnt += 1
                endflg = True
        elif i == 'Z' and endflg:
                cnt += 1
        elif endflg
                break
        elif cntflg:
                cnt += 1
        elif i == 'A' and not(cntflg):
                cnt = 1
                cntflg = True

print(cnt)

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
cntflg = True
for i in s:
  if i == 'Z':
    break
  elif cntflg:
    cnt += 1
  elif i == 'A'
  	cnt = 1
    cntflg = True

print(cnt)

Submission status: Runtime Error

Solution code:
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    flagA = True

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)

Submission status: Runtime Error

Solution code:
s=input()
l=len(s)
x,y=0
for i in range(l):
  if s[i]=='A':
    x=i
    break
for j in range(l-1,0,-1):
  if s[j]=='Z':
    y=j
    break
print(y-x+1)

Submission status: Runtime Error

Solution code:
s = input()
a=0
z=0

for i in range(len(s)):
    if s[i]=="A":
        a = i
        break

for j in range(len(s)):
    if s[-j-1]=="Z":
        z = len(s)-j-1
		break
print(z-a+1)

Submission status: Runtime Error

Solution code:
S = input()
dAdAd1 1
a = S.find('A')

b = S.find('Z')

print(len(S)-a-b)

Submission status: Runtime Error

Solution code:
s = input()

for i in range(n):
  if s[i] == "A":
    l = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "Z":
    r = i
    break
print(s[l:r+1])

Submission status: Runtime Error

Solution code:
s = input()

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)

Submission status: Runtime Error

Solution code:
s=list(input())
print((s.index('z')-s.index('a'))+1)

Submission status: Runtime Error

Solution code:
s=input()
a=s.find("A")
z0=s.count("Z")
for i in range (z0-1):
    s=s[:s.find("Z")]+"a"+s[s.find("Z")+1:]
    z=s.find("Z")
print(z-a+1)

Submission status: Runtime Error

Solution code:
s=input()
a=s.find("a")
z0=s.count("z")
for i in range (z0-1):
    s=s[:s.find("z")]+"a"+s[s.find("z")+1:]
    z=s.find("z")
print(z-a+1)

Submission status: Runtime Error

Solution code:
s=input()
for i in range(len(s)):
  if s[i]==`A`:
    a=i
    break
for i in reversed(range(len(s))):
  if s[i]==`Z`:
    b=i
    break
print(b-a)

Submission status: Runtime Error

Solution code:
s = input()
n = len(n)
aind = 0
for i , c in enumerate(s):
  if c == "A":
    aind =  i
    break
zind = 0
for i,c in enumerate(s):
  if c == "Z":
    zind = i
    
print(zind-aind)

Submission status: Runtime Error

Solution code:
s=input()
for i in range(len(s)):
    if s[i]=="A":
        a=i
for i in range(a+1,len(s)):
    if s[i]=="Z":
        z=i
print(z-a+1)

Submission status: Runtime Error

Solution code:
package main

import "fmt"

func main() {
  var s string
  start := -1
  end := -1

  fmt.Scanf("%s", &s)
  for i, _ := range s {
    if s[i:i+1] == "A" && start == -1 {
      start = i
    }
    if s[i:i+1] == "Z" {
      end = i
    }
  }
  fmt.Println(end-start+1)
}

Submission status: Runtime Error

Solution code:
S = input()
min_ = 0
max_ = 0
flag_min = False
for i in len(S):
  if flag_min:
    if S[i] == "A":
      min_ = i
      flag_min = True
  else:
    if S[i] == "Z":
      max_ = i
      
print(max_ - min_ + 1)

Submission status: Runtime Error

Solution code:
s = input()
head = s.fine("A")
tail = s.rfind("Z")
print(tail - head +1)

Submission status: Runtime Error

Solution code:
s=input()

for i in range(0,len(s)):
    if s[i] == "A":
        a = i
        break
for i in range(a,len(s)):
    if s[i] == "Z":
        z = i
        break
print(len(s[a:z+1])

Submission status: Runtime Error

Solution code:
s = str(input())

a = 0
z = 0

for i in range(len(s)):
    if s[i] = "A":
        a = min(a,i)

    elif s[i]  = "Z":
        z = max(z,i)

print(z - a + 1)

Submission status: Runtime Error

Solution code:
string = input()
string_list = [s for s in string]

def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)

index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)

print(index_of_z[-1] - index_of_a[0]+1)