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: Wrong Answer

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

print(N - z_index - a_index)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s_list = list(input())
a_num = 0
z_num = 0
for i,a in enumerate(s_list):
    if a == 'A':
        a_num = i
        break
rs_list = reversed(s_list)
for j,z in enumerate(rs_list):
    if z == 'Z':
        z_num = j
        break
print(a_num,z_num,)
if z_num == 0:
    print(len(s_list[a_num:]))
else:
    print(len(s_list[a_num:-z_num]))

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
for i in range(len(s)):
  if s[i]=='A':
    for j in range(len(s)-i):
    	if s[i+j]=='Z':
          ans=i+j
print(ans)

Submission status: Wrong Answer

Solution code:

s=str(input())
atoz=[]
for i in range(len(s)):
	if(s[i]=="A"):
		a=i
		break
#print(a)


for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)
#print(s_l)

r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	#print(i)
	if(i!="Z"):
		s_l.pop()
#		print(s_l)
	else:
		break
#	r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
print(str_s_l)

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
for i in range(len(s)):
    if s[i] == 'A':
        for j in range(len(s)-1,0,-1):
            print(i,j)
            if s[j] == 'Z':
                if ans < abs(i-j):
                    ans = abs(i-j)
                break

print(ans+1)

Submission status: Wrong Answer

Solution code:
s = input()
print(len(s[s.find('A'):s.rfind('Z')]))

Submission status: Wrong Answer

Solution code:
s = input()
print(s[s.find('A'):s.rfind('Z')])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

a, b = s.find('A'), s.rfind('Z')
print(s[a:b + 1])

Submission status: Wrong Answer

Solution code:
S = input()
start_flag = False
start = 200001
end = 200001
for i in range(len(S)):
    if S[i] == "A" and start_flag == False:
        start_flag = True
        start = i
    elif S[i] == "Z" and start_flag == True:
        end = i
        break
print(end-start+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
lp = 0
rp = len(s)
for c in s:
  if c == 'A':
    break
  lp+=1
for c in s[:-1]:
  if c == 'Z':
    break
  rp-=1
print(len(s[lp:rp]))

Submission status: Wrong Answer

Solution code:
s=input()
#print(s)
cnt=0
flag1=0
flag2=0

for i in range(len(s)):
  if s[i]=='A':
    flag1=1
  if flag1==1 and flag2==0:
    cnt+=1
  if flag1==1 and s[i]=='Z':
    flag2=1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
s=input()
st=s.find("A")
ed=s.rfind("Z")
print(s[st:ed+1])

Submission status: Wrong Answer

Solution code:
s = input()

a = 0
for n, i in enumerate(reversed(s)):
    if i == "Z":
        a = len(s) - n

b = 0
for n, i in enumerate(s):
    if i == "A":
        b = n

print(a - b)

Submission status: Wrong Answer

Solution code:
s = list(input())
flag = 0
start = 0
end = 0
for i in range(len(s)):
    if s[i] == 'A':
        flag = 1
        start = i

    if flag == 1 and s[i] == 'Z':
        end = i
        break
print(end - start + 1)

Submission status: Wrong Answer

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest053-B
#  https://beta.atcoder.jp/contests/abc053/tasks/abc053_b

def atozString(dataStr) :

	rangeFirstToEnd = range(0,len(dataStr),1)
	rangeEndToFirst = range(len(dataStr)-1,-1,-1)
	firstA = 0
	lastZ = len(dataStr)
	for i in rangeFirstToEnd:
		if dataStr[i] == 'A':
			firstA = i
			break

	for i in rangeEndToFirst:
		if dataStr[i] == 'Z':
			lastZ = i
			break

	print(dataStr[firstA:lastZ+1])
	answerInt = lastZ-firstA+1
	return answerInt


if __name__ == '__main__':
	inputLine = input()
	inputStr = inputLine
	ans=atozString(inputStr)
	print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(len(s)):
    if(s[i] == 'A'):
        t = i
    if(s[i] == 'Z'):
        b = i

print(b-t+1)

Submission status: Wrong Answer

Solution code:
s = input().strip()

a = 0
b = 0

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

Submission status: Wrong Answer

Solution code:
a = input()
b = a[a.index('A'):a.rindex('Z')+1]

Submission status: Wrong Answer

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

for i in range(len(s)):
    if(s[i]=="A" and a<=i and i<=z):
        a=i
    elif(s[i]=="Z" and z<=i ):
        z=i

print(z-a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
text = input()
a_list = []
z_list = []
for i, x in enumerate(text):
    if x == "A":
        a_list.append(i)
    if x == "Z":
        z_list.append(i)

print(a_list)
print(z_list)
a_z_len = max(z_list) - min(a_list) + 1
print(a_z_len)

Submission status: Wrong Answer

Solution code:
text = input()
a_list = []
z_list = []
for i in text:
    if i == "A":
        a_list.append(text.index(i))
    if i == "Z":
        z_list.append(text.index(i))

if a_list and z_list:
    a_z_len = max(z_list) - max(a_list) + 1
    if a_z_len > 0:
        print(a_z_len)
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
text = input()
a_list = []
z_list = []
for i in text:
    if i == "A":
        a_list.append(text.index(i))
    if i == "Z":
        z_list.append(text.index(i))

a_z_len = max(z_list) - min(a_list) + 1
print(a_z_len)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python3
# A to Z String
""" 文字列から 'A***Z' のような文字列を抜き出す """

s = input()
list_s = list(s)

test = True

def length_AZ(l):
    """ 最初の'A'と最後の'Z'の位置の差を返す関数"""
    len_l = len(l)
    index_A = []
    index_Z = []

    for i in range(len_l):
        if l[i] == 'A':
            index_A.append(i)
        elif l[i] == 'Z':
            index_Z.append(i)

    if test:
        print('index_A =', index_A)
        print('index_Z =', index_Z)

    return max(index_Z) - min(index_A) + 1


def main():
    """ 答えを出力する """
    print(length_AZ(list_s))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
a = 0
z = -1
while 1:
    if s[a] == 'A':
        break
    a+=1
while 1:
    if s[z] =='Z':
        break
    z-=1
print(s[a:z+1])

Submission status: Wrong Answer

Solution code:
a = input().split("A")
ans = 0
temp = 0
for i in range(1, len(a)):
    if "Z" not in a[i]:
        temp += len(a[i])+1
    else:
        temp += a[i].rindex("Z")+2
        ans = max(ans, temp)
        temp = 0
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = ""
maxct = 0
aflg = False
for i in range(len(s)):
    if s[i] == "A":
        aflg = True
    if aflg == True:
        ans += s[i]
    if s[i] == "Z":
        aflg = False
        if maxct < len(ans):
            maxct = len(ans)
        ans = ""
print(maxct)

Submission status: Wrong Answer

Solution code:
S = input()
SS = S[::-1]
ind_A = S.index('A')
ind_Z = SS.index('Z')
if S != 'AZ':
    print(len(S[ind_A:ind_Z*-1]))
else:
    print(2)

Submission status: Wrong Answer

Solution code:
S = input()
SS = S[::-1]
ind_A = S.index('A')
ind_Z = SS.index('Z')
print(len(S[ind_A:ind_Z*-1]))

Submission status: Wrong Answer

Solution code:
S = input()
SS = S[::-1]
ind_A = S.index('A')
ind_Z = SS.index('Z')
print(S[ind_A:ind_Z*-1])

Submission status: Wrong Answer

Solution code:
S = input()
SS = S[::-1]
ind_A = S.index('A')
ind_Z = SS.index('Z')
print(len(S[ind_A:ind_Z]))

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)

i = 0
while i<n:
  if s[i] == "a":
    break
  i += 1
j=n-1
while j>0:
  if s[j] == "z":
    break
  j -= 1
print(j-i+1)

Submission status: Wrong Answer

Solution code:
s = input()

ans = []
flag = 0

#print(s)
#print(s[0])

for i in range(len(s)):
    if flag == 0:
        if s[i] == "A":
            flag = 1
            ans.append(s[i])

    else:
        if s[i] == "Z":
            if i >= len(s) - 1 or s[i+1] != "Z":
                flag = 0
                ans.append(s[i])
                break
            
            else:
                ans.append(s[i])

        else:
            ans.append(s[i])
        

#print(ans)

#print("".join(ans))

print(len(ans))

Submission status: Wrong Answer

Solution code:
s=input()
x=s.find('A')
y=s.find('Z')
print(y-x+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = input()
N = len(A)
print(A)
for i in range(N):
    if A[i] == 'A':
        S = i
        break
for i in range(N):
    if A[N-i-1] == 'Z':
        E = i
        break
print(N - S - E)

Submission status: Wrong Answer

Solution code:
s = input()

start = s.index("A")

for i in range(len(s)-1, start, -1):
    print(i)
    if s[i] == "Z":
        print(i - start + 1)
        break

Submission status: Wrong Answer

Solution code:
s = input()

start = s.index("A")

for i in range(start, len(s)):
    if s[i] == "Z":
        print(i - start + 1)
        break

Submission status: Wrong Answer

Solution code:
s = input()
a = f = 0
for i in range(len(s)):
    if s[i] == "A" or f == 1:
        f = 1
        a += 1
    if s[i] == "Z":
        f = 0
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

flag = False
start = 0
end = 0
for i in range(len(s)):
    if start == 0 and s[i] == 'A':
        flag = True
        start = i
    if s[i] == 'Z':
        end = i
if flag:
    print(end - start + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
s = input()

start = 0
end = 0
for i in range(len(s)):
    if start == 0 and s[i] == 'A':
        start = i
    if s[i] == 'Z':
        end = i
print(end - start + 1)

Submission status: Wrong Answer

Solution code:
S = input()
a = S.index("A")
z = S.index("Z")
print(z - a + 1)

Submission status: Wrong Answer

Solution code:
a = input()
b = ""
counterf=0
counter =0

for x in a:
    if x == "A":
        b+=x
        counterf +=1
    elif counterf ==1:
        b+=x
        if x == "Z":
            break
    counter+=1
print(len(b))

Submission status: Wrong Answer

Solution code:
s = input()
max = 2
tmp = 0
flag = 0
for i in range(len(s)):
    if s[i] == 'A':
        flag = 1
    if flag:
        tmp += 1
    if s[i] == 'Z':
        if i < len(s)-1  and s[i+1] == 'Z':
            continue
        if max < tmp:
            max = tmp
        tmp = 0
        flag = 0
print(max)

Submission status: Wrong Answer

Solution code:
s = input()
max = 2
tmp = 0
flag = 0
for i in range(len(s)):
    if s[i] == 'A':
        flag = 1
    if flag:
        tmp += 1
    if s[i] == 'Z':
        if i < len(s)-2  and s[i+1] == 'Z':
            continue
        if max < tmp:
            max = tmp
        tmp = 0
print(max)

Submission status: Wrong Answer

Solution code:
atoz = list(input())
A_num = 0
Z_num = 0
for i, j in enumerate(atoz):
    if j == "A" and A_num == 0:
        A_num = i
    elif j == "Z" and A_num < i:
        Z_num = i
    else:
        pass
    
print(Z_num - A_num+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
a = s.find("a")
z = s.find("z")
print(z - a)

Submission status: Wrong Answer

Solution code:
s=input()

Aindex = s.find("A")
Zindex = -1

for index,character in enumerate(s[Aindex:]):
    if character == "Z":
        Zindex = index

print(len(s[Aindex:Zindex+1]))

Submission status: Wrong Answer

Solution code:
s=input()

Aindex = s.find("A")
Zindex = -1

for index,character in enumerate(s[Aindex:]):
    if character == "Z":
        Zindex = index

print(s[Aindex:Zindex+1])

Submission status: Wrong Answer

Solution code:
str = input('')
start = 0
end = 0
for x in range(len(str)):
  if str[x] == 'A' and start == 0:
    start = x
  elif str[x] == 'Z':
    end = x
print(end - start + 1)

Submission status: Wrong Answer

Solution code:
str = input('')
start = 0
end = 0
for x in range(len(str)):
  if str[x] == 'A' and start == 0:
    start = x
  elif str[x] == 'Z':
    end = x
print(start)
print(end)
print(end - start + 1)

Submission status: Wrong Answer

Solution code:
str = input('')
start = 0
end = 0
for x in range(len(str)):
  if str[x] == 'A' and start != 0:
    start = x
  elif str[x] == 'Z':
    end = x
print(end - start + 1)

Submission status: Wrong Answer

Solution code:
S = input()
print(len(S) -S[::-1].find("Z") -S.find("A") +2)

Submission status: Wrong Answer

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()


s = arr_data[0][0]


#print(s)

aposi = 0
zposi = 0
aflg = False
zflg = False
cnt = 0
for v in range(0, len(s)):
    
#    print(s[v],aflg)
    
    if s[v] == "A" and aflg and zflg:
    
        print(aposi,zposi,cnt)
        if cnt < zposi-aposi+1:
            
            cnt = zposi - aposi+1

            aflg = False
            zflg = False
            
        else:
        
            aflg=False
            zflg=False
            
    
    if s[v] == "A" and aflg==False:
        
#        print(v)
        aposi = v
        aflg = True
    
    if s[v] == "Z" and aflg==True:
    
        zposi = v
        zflg = True
#        print(v)
    

        
if aflg and zflg:

#    print(aposi,zposi,cnt)
    if cnt < zposi-aposi+1:

        cnt = zposi - aposi + 1
    
    print(cnt)    

else:
       
    print(cnt)

Submission status: Wrong Answer

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()


s = arr_data[0][0]


#print(s)

aposi = 0
zposi = 0
aflg = False
zflg = False
cnt = 0
for v in range(0, len(s)):
    
#    print(s[v],aflg)
    
    if s[v] == "A" and aflg and zflg:
    
#        print(aposi,zposi,cnt)
        if cnt < zposi-aposi:
            
            cnt = zposi - aposi+1

            aflg = False
            zflg = False
            
        else:
        
            aflg=False
            zflg=False
            
    
    if s[v] == "A" and aflg==False:
        
#        print(v)
        aposi = v
        aflg = True
    
    if s[v] == "Z" and aflg==True:
    
        zposi = v
        zflg = True
#        print(v)
    

        
if aflg and zflg:

#    print(aposi,zposi)
    if cnt < zposi-aposi:

        cnt = zposi - aposi + 1
    
    print(cnt)    

else:
       
    print(cnt)

Submission status: Wrong Answer

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()


s = arr_data[0][0]


#print(s)

aposi = 0
zposi = 0
aflg = False
zflg = False
cnt = 0
for v in range(0, len(s)):
    
#    print(s[v],aflg)
    
    if s[v] == "A" and aflg and zflg:
    
#        print(aposi,zposi,cnt)
        if cnt < zposi-aposi:
            
            cnt = zposi - aposi+1

            aflg = False
            zflg = False
            
    
    if s[v] == "A" and aflg==False:
        
#        print(v)
        aposi = v
        aflg = True
    
    if s[v] == "Z" and aflg==True:
    
        zposi = v
        zflg = True
#        print(v)
    

        
if aflg and zflg:

#    print(aposi,zposi)
    if cnt < zposi-aposi:

        cnt = zposi - aposi + 1
    
    print(cnt)    

else:
       
    print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

before = s.find('A')
after = s.find('Z')

print(after - before)

Submission status: Wrong Answer

Solution code:
s = input()
isAdd = False
ans = 0 
cur = 0
for c in s:
    if c == 'A': isAdd = True
    if isAdd:
        cur += 1
        ans = max(ans, cur)
    if c == 'Z' and isAdd:
        isAdd = False
        cur = 0

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
isAdd = False
ans = 0 
cur = 0
for c in s:
    if c == 'A': isAdd = True
    if isAdd:
        cur += 1
        ans = max(ans, cur)
    if c == 'Z' and isAdd: isAdd = False

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
isAdd = False
ans = 0
for c in s:
    if c == 'A': isAdd = True
    if c == 'Z' and isAdd: isAdd = False
    if isAdd: ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
isAdd = False
ans = 0
for c in s:
    if c == 'A': isAdd = True
    if isAdd: ans += 1
    if c == 'Z' and isAdd: isAdd = False

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
a=s.find("A")
b=s.rfind("Z")
print(s[a:b])

Submission status: Wrong Answer

Solution code:
s = list(input())
i_tmp1 = 200001

for i in range(len(s)):
   if s[i] == "A":
      i_tmp1= i
   elif s[i] == "Z" and i >= i_tmp1:
      i_tmp2  = i

print(i_tmp2-i_tmp1+1)

Submission status: Wrong Answer

Solution code:
s = list(input())
i_tmp1 = 200001

for i in range(len(s)):
   if s[i] == "A":
      i_tmp1= i
   elif s[i] == "Z" and i >= i_tmp1:
      i_tmp2  = i
      break

print(i_tmp2-i_tmp1+1)

Submission status: Wrong Answer

Solution code:
s = list(input())
i_tmp1 = -1

for i in range(len(s)):
   if s[i] == "A":
      i_tmp1= i
   elif s[i] == "Z" and i >= i_tmp1:
      i_tmp2  = i

print(i_tmp2-i_tmp1+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

a_found = False
z_found = False
temp = 0
length = 0

for i in s:

  if i == "A":
    a_found = True
  elif i == "Z":
    z_found = True
    
  if z_found == True and a_found == True:
    if temp > length:
      length = temp

    if not i == "Z":
      z_found = False
      temp = 0
  
  if i == "A":
    a_found = True

  if a_found == True:
    temp += 1

  if temp > length:
    length = temp
  print(temp, a_found, z_found)
print(length)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solution():
	a = raw_input()
		
	aIdx = 0
	zIdx = 0
	maxLength = 0

	for i in range(len(a)):
		if a[i] == 'A' and aIdx == 0:
			aIdx = i
		
		if a[i] == 'Z':
			zIdx = i 

	print zIdx - aIdx + 1

solution()

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    S = input()
    A = 2 ** 100
    Z = 2 ** 100
    res = 0
    for x,y in enumerate(S):

        if y == 'A':
            A = x
        if y == 'Z':
            Z = x
            res = max(res, (Z - A) + 1)
    print (res)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    S = input().split()
    A = 2 ** 100
    Z = 2 ** 100
    res = 0
    for x,y in enumerate(S):
        if y == 'A':
            A = x
        if y == 'Z':
            Z = x
            res = max(res, (Z - A) + 1)
    print (res)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    S = input().split()
    A = -1
    Z = -1
    res = 0
    for x,y in enumerate(S):
        if y == 'A':
            A = x
        if y == 'Z':
            Z = x
            res = max(res, (Z - A) + 1)
    print (res)

Submission status: Wrong Answer

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

a = s.find("A")
z = s.rfind("Z")
ans = z - a + 3
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
rev=s[::-1]
n=len(s)
print((n-rev.find('Z')) - (s.find('A') + 1))

Submission status: Wrong Answer

Solution code:
s = []
s = input()
min_a = 0
max_z = 0
for i in range(len(s)):
  if s[i]=='A' and min_a==0:
    min_a = i
  elif s[i]=='Z':
    max_z = i
 
print(max_z-min_a+1)

Submission status: Wrong Answer

Solution code:
s = []
s = input()
min_a = 0
max_z = 0
for i in range(len(s)):
  if s[i]=='A' and min_a==0:
    min_a = i
  elif s[i]=='Z':
    max_z = i

print(max_z-min_a+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(input())

cnt = 0
on = False
result = []
for a in s:
    if a is 'A':
        on = True
    elif a is 'Z':
        result.append(cnt)
        cnt += 1
    if on:
        cnt += 1

print(max(result))

Submission status: Wrong Answer

Solution code:
s = list(input())
cnt = 0
n = 1
for i in range(len(s)):
    if s[i] == "A":
        while s[i+n] != "Z":
            n += 1
        try:
            while s[i+n] == "Z":
                n += 1
        except:
            pass
        break
print(n)

Submission status: Wrong Answer

Solution code:
s = list(input())
cnt = 0
n = 1
for i in range(len(s)):
    if s[i] == "A":
        while s[i+n] != "Z":
            n += 1
        try:
            while s[i+n] == "Z":
                n += 1
        except:
            pass
        break
print(n)

Submission status: Wrong Answer

Solution code:
s = list(input())
cnt = 0
n = 1
t = 1
for i in range(len(s)):
    if s[i] == "A":
        while s[i+n] != "Z":
            n += 1
        try: 
            while s[i+n+t] == "Z":
                n += 1
                t += 1
        except:
            pass
        break
print(n+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
if __name__ == '__main__':
  s = str(input())
  L = len(s)
  beg = -1
  end = -1
  for i in range(0,L):
    if s[i]=='A' and beg==-1:
      beg = i
    elif s[i]=='Z':
      end = i
  print(s[beg:end-beg+1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

s = raw_input()
indexA = -1
indexZ = -1

for num in range(len(s)):
	if bool(indexA == -1 and s[num] == "A"):
		indexA = num - 1
	if s[num] == "Z":
		indexZ = num

print(indexZ - indexA)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

s = raw_input()
indexA = -1
indexZ = -1

for num in range(len(s)):
	if bool(indexZ == -1 and s[num] == "A"):
		indexA = num - 1
	if s[num] == "Z":
		indexZ = num

print(indexZ - indexA)

Submission status: Wrong Answer

Solution code:








def sol(strs):

	ptrA=0;
	ptrZ=len(strs)

	for i in range(len(strs)):
		if strs[i]=="A":
			ptrA=i
			break

	for i in range(len(strs),0):
		if strs[i]=="Z":
			ptrZ=i
			break

	return (ptrZ - ptrA)





inD =raw_input()

inD = str(inD)

print sol(inD)

Submission status: Wrong Answer

Solution code:
inD =raw_input()

inD = str(inD)

count=0
statusFlag=False

for obj in inD:

	if obj =="A":
		statusFlag=True
	elif obj =="Z":
		statusFlag=False
	elif statusFlag == True:
		count+=1

count+=2
print count

Submission status: Wrong Answer

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

def main():
    a = list(input())
    i = a.index('A')
    while(a.index('Z') < i):
        a.pop(a.index('Z'))
    print(a.index('Z') - i + 2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(len(s)):
    
    if s[i]=='A' and start==0:
        start = i
        
    if s[i]=='Z' and end!=len(s):
        end = i

print(end-start+1)

Submission status: Wrong Answer

Solution code:
import sys
s = input();

i = 0
j = 0
for c in s:
    if c == 'A':
        j = i
        while True:
            if s[j] == 'Z':
                print(j-i + 1)
                sys.exit(0)
            else :
                j = j + 1
    i = i + 1

Submission status: Wrong Answer

Solution code:
import sys
s = input();

i = 0
j = 0
for c in s:
    if c == 'A':
        j = i
        while True:
            if s[j] == 'Z':
                print(j-i)
                sys.exit(0)
            else :
                j = j + 1
    i = i + 1

Submission status: Wrong Answer

Solution code:
import sys
s = input();
length = len(s)
i = 0
j = 0
print(length)
for c in s:
    if c == 'A':
        j = i
        while True:
            if s[j] == 'Z':
                print(j-i)
                sys.exit(0)
            else :
                j = j + 1
    i = i + 1

Submission status: Wrong Answer

Solution code:
s=raw_input()
n=len(s)
for i in xrange(n):
    if s[i]=="A":
        idx1=i
        break    
for i in xrange(n-1,0,-1):
    if s[i]=="Z":
        idx2=i
        break

Submission status: Wrong Answer

Solution code:
s = input()
start = s.index("A")
fin = s.rindex("Z")
ans = s[start:fin+1]
print(len(ans),ans)

Submission status: Wrong Answer

Solution code:
s = input()
start = s.index("A")
fin = s.index("Z")
ans = s[start:fin]
print(len(ans))

Submission status: Wrong Answer

Solution code:
s = input()


def get_z_idx(s):
    l = len(s) - 1
    for i in range(l, -1, -1):
        if s[i] == 'Z':
            z_idx = i
            break
    return z_idx


def main(s):
    a_idx = s.index('A')
    z_idx = get_z_idx(s)
    _s = s[a_idx:z_idx + 1]
    return _s


print(main(s))

Submission status: Wrong Answer

Solution code:
s = input()

f = -1
b = -1
i = 0
n = len(s) - 1

while f == -1 or b == -1:
    if s[i] == 'A':
        f = i
    if s[n] == 'Z':
        b = n
    i = i + 1
    n = n - 1

print(b - f + 1)

Submission status: Wrong Answer

Solution code:
s = input()

a_i = None
z_i = None

for i in range(len(s)):
    if (not a_i) and s[i] == 'A':
        a_i = i
    if s[i] == 'Z':
        z_i = i

print(z_i - a_i + 1)

Submission status: Wrong Answer

Solution code:
s = raw_input()
memo1 = 0
memo2 = 0
cnt = 0
for x in s:
    if x == "A":
        memo1 = cnt
    elif x == "Z":
        memo2 = cnt
    cnt += 1

print memo2 - memo1 + 1

Submission status: Time Limit Exceeded

Solution code:
s = list(input())

while s[0] != 'A':
    s.pop(0)

while s[-1] != 'Z':
    s.pop()

print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
maxi = 0

for i in range(len(s)):
    if s[i] == 'A':
        for j in range(i, len(s)):
            if s[j] == 'Z' and j-i+1 > maxi:
                maxi = j-i+1

print(maxi)

Submission status: Time Limit Exceeded

Solution code:
s = input()

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

for i in range(len(s)):
  if s[::-1][i] == "Z":
    en = len(s)-i
    break

print(en - st + 1)

Submission status: Time Limit Exceeded

Solution code:
s = list(input())

a_index_list = [i for i, v in enumerate(s) if v == min(s)]
z_index_list = [i for i, v in enumerate(s) if v == max(s)]

print(z_index_list[-1] - a_index_list[0] + 1)

Submission status: Time Limit Exceeded

Solution code:
s=input()
A=[]
B=[]
for i in range(len(s)):
    for j in range(len(s)):
        if i<j and s[i]=='A' and s[j]=='Z':
            A.append(j+1-i)
print(max(A))

Submission status: Time Limit Exceeded

Solution code:
s=input()
A=[]
B=[]
for i in range(len(s)):
    for j in range(len(s)):
        if i<j and s[i]=='A' and s[j]=='Z':
            A.append(s[i:j+1])
for i in range(len(A)):
    B.append(len(A[i]))
print(max(B))

Submission status: Time Limit Exceeded

Solution code:
s = input()
length = 0
maxLength = 0
for i in range(len(s)):
    if s[i] != "A":
        continue
    for j in range(i+1, len(s)):
        if s[j] != "Z":
            continue
        length = abs(j+1 - i)
        if maxLength < length:
            maxLength = length
print(maxLength)