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()
for i in range(len(s)):
    if s[i] == 'A':
        start = i
        break
for i in range(1,len(s)):
    if s[-i] == 'Z':
        end = i
        break
print(len(s[start:-end+1]))

Submission status: Wrong Answer

Solution code:
string = input().upper()
x = string.index("A") ; y = string.index("Z")
z = string[x:y+1]
print(len(z))

Submission status: Wrong Answer

Solution code:
s = input()
t = s[::-1]

for i in range(len(s)):
  if s[i] == "A":
    break
for j in range(len(t)):
  if t[j] == "Z":
    break
print(len(s[i:-j]))

Submission status: Wrong Answer

Solution code:
s = input()
x = len(s)
y = 0
z = 0
a = x - 1
while(y <= x):
  if (s[y] == "A"):
    z = y
    break
  y += 1
while(y <= x):
  if (s[a]  == "Z"):
    print(str(a - z))
    break
  a -= 1
  y += 1

Submission status: Wrong Answer

Solution code:
s = input()
x = len(s)
y = 0
z = 0
while(y <= x):
  if (s[y] == "A"):
    z = y
    break
  y += 1
while(y <= x):
  if (s[y]  == "Z"):
    print(str(y - z + 1))
    break
  y += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
t=0
flug=0

for i in s:
    if flug==0:
        if i=="A":
            flug=1
            t+=1
            
    elif flug==1:
        if i=="Z":
            flug=2
            t+=1
        else:
            t+=1
    else:
        if i=="Z":
            t+=1
        elif i=="A":
            ans=max(ans,t)
            t=1
            flug=1
        else:
            ans=max(ans,t)
            t=0
            flug=0

ans=max(ans,t)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = str(input())
a = s.find("A")
z = s.find("Z")
print(len(s[a:z + 1]))

Submission status: Wrong Answer

Solution code:
s=input()
frag=False
count=0
ans=0
for i in range(len(s)):
    if frag:
        count+=1
    if s[i]=="A":
        frag=True
        count+=1
    elif s[i]=="Z" and frag:
        frag=False
        ans=max(ans,count)

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
frag=False
count=0
ans=0
for i in range(len(s)):
    if frag:
        count+=1
    if s[i]=="A":
        frag=True
        count+=1
    elif s[i]=="Z":
        frag=False
        ans=max(ans,count)

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())

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

Submission status: Wrong Answer

Solution code:
str=input()
ans=[]
head,end=0,0
flag = False

for i,val in enumerate(str):
	if val=='A':
		head=i
		ans.append(val)  
		flag=True
		continue
	if val is not 'Z'and flag==True:
		ans.append(val)
		end=i
		continue
	elif val is 'Z' and flag==True:
		break
answer= ''.join(ans)
print(len(answer[head:end])+2)

Submission status: Wrong Answer

Solution code:
str=input()
ans=[]
head,end=0,0

for i,val in enumerate(str):
	if val=='A':
		head=i
		ans.append(val)  
		continue
	elif val is not 'Z':
		ans.append(val)
		end=i
		continue
	elif val is 'Z':
		break
answer= ''.join(ans)
print(len(answer[head:end])+2)

Submission status: Wrong Answer

Solution code:
str=input()
ans=[]
head,end=0,0

for i,val in enumerate(str):
	if val=='A':
		head=i
		ans.append(val)  
		continue
	elif val is not 'Z':
		ans.append(val)
		end=i
		continue
	elif val is 'Z':
		break
answer= ''.join(ans)
print(len(answer[head:end+2]))

Submission status: Wrong Answer

Solution code:
str=input()
ans=[]
head,end=0,0

for i,val in enumerate(str):
	if val=='A':
		head=i
		ans.append(val)  
		continue
	elif val is not 'Z':
		ans.append(val)
		end=i
		continue
	elif val is 'Z':
		break
answer= ''.join(ans)
print(len(answer[head:end+1]))

Submission status: Wrong Answer

Solution code:
str=input()
ans=[]
head,end=0,0

for i,val in enumerate(str):
	if val=='A':
		head=i
		ans.append(val)  
		continue
	elif val is not 'Z':
		ans.append(val)
		end=i
		continue
	elif val is 'Z':
		break
answer= ''.join(ans)
print(answer[head:end+1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

s = input()
c = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re

s = input()
res = re.search('A[A-Z]+Z', s)
print(res.end())

Submission status: Wrong Answer

Solution code:
s = input()
a_index = 0
z_index = 0

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

Submission status: Wrong Answer

Solution code:
s = input()
a_index = 0
z_index = 0

for i in range(0, len(s)):
    if s[i] == "A":
        a_index = i
        break
        
for i in range(0, len(s)):
    if s[len(s)-i-1] == "Z":
        z_index = len(s)-i
        break
print(s[a_index:z_index])

Submission status: Wrong Answer

Solution code:
#53B A to Z String
s=list(input())
flag=0
ans2=[]
for i in range(len(s)):
    if s[i]=="A":
        flag=1
        ans2.append(i)
    elif s[i]=="Z" and flag==1:
        ans2.append(i)
        if i==len(s)-1 or s[i+1]!="Z":
            break
    elif flag==1:
        ans2.append(i)
print(len(ans2))

Submission status: Wrong Answer

Solution code:
s=input()

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

Submission status: Wrong Answer

Solution code:
line = input()
a = 20000000
z = 0
for i in range(len(line)):
  if line[i] == 'A':
    min(a,i)
  elif line[i] == 'Z':
    max(z,i)
print(z-a+1)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    for i in range(len(s)):
        if s[i]=="a":break
    for j in range(len(s)-1,-1,-1):
        if s[j]=="z":break
    print(j-i+1)

main()

Submission status: Wrong Answer

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-1] == "Z":
    u = n-j-1
print(u-t+1)

Submission status: Wrong Answer

Solution code:
s = input()
a = 0

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

print(z - a + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = str(input())
Acount = 0
Zcount = 0
for i in range (len(s)):
    if s[i] == 'A':
        Acount = i
        break

for j in range (len(s)):
    if s[j] == 'Z':
        Zcount = j

print(j - i +1)

Submission status: Wrong Answer

Solution code:
l = list(input())

for i in range(len(l)):
  if l[i] == "A":
    a = i
    break
for i in range(len(l)):
  if l[-1-i] == "Z":
    b = i
    break
print(b-a+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
    if find_a==0 and s[a]=="A":
        find_a=1
    if find_z==0 and s[z]=="Z":
        find_z=1
    if find_a==0:
        a+=1
    if find_z==0:
        z-=1
print(z,a)
print(z-a+1)

Submission status: Wrong Answer

Solution code:
s = input()
num = len(s)
A = s.find("A")
Z = s.rfind("Z")
ans = Z - A
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

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:
s = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha_rem = alpha.strip("AZ")

print(len(s.strip(alpha_rem)))

Submission status: Wrong Answer

Solution code:
s=input()

ans=0
flag=False
n=0
for i in range(len(s)):
    if s[i]=="A":
        flag=True
        n+=1
        continue
    if s[i]=="Z":
        if flag:
            n+=1
            ans=max(ans,n)
            n=0
            flag=False
            continue
    if flag:
        n+=1
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
print(s[s.index("A"):s.rindex("Z")+1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

s=input()
a=0
z=0

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

s=input()
a=0
z=0

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



print(z-a+1)

Submission status: Wrong Answer

Solution code:
s = input()
l = s.find('A')
r = s.rfind('Z')
ans = s[l:r+1]
print(ans)

Submission status: Wrong Answer

Solution code:
str = input()
count = -1
answer = 0
for id in range(len(str)):
    if str[id] == "A": count = 0
    if count == -1: continue
    count += 1
    if str[id] == "Z": 
        answer = max(answer, count)
        count = -1
print(answer)

Submission status: Wrong Answer

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 i in reversed(range(l)):
    if s[i] =="Z":
        end = s.index(s[i])
        break
Ans=end-start+1
print(Ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()

    for i in range(len(S)):
        if S[i] == 'A': a = i
    for i in range(len(S) - 1, -1 , -1):
        if S[i] == 'Z': z = i

    print(z - a + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

left, right = s.find('A'), s.rfind('B')
print(right-left+1)

Submission status: Wrong Answer

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[sa:sz+1]))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
s = input().rstrip()
s_rev = s[::-1]
mina = -1
maxz = -1
for i in range(len(s)):
    if s[i] == "A":
        mina = i
for j in range(len(s)):
    if s[j] == "Z":
        maxz = max(maxz, j)
print(maxz - mina + 1)

Submission status: Wrong Answer

Solution code:
data = input()
Anull = True
Znull = True
count=0
zc=0
for i in range(len(data)):
  if Anull and data[i]=="A":
    Anull = False
    count=i
  if Znull and data[-1*i] == "Z":
    Znull = False
    zc=len(data)-i
result = zc - count + 1
print(result)

Submission status: Wrong Answer

Solution code:
data = input()
Anull = True
count=0
zc=0
for i in range(len(data)):
  if Anull and data[i]=="A":
    Anull = False
    count=i
  if zc == 0 and data[-1*i] == "Z":
    zc=len(data)-i
result = zc - count + 1
print(result)

Submission status: Wrong Answer

Solution code:
s=input()

A = 0
Z = 0

for index, i in enumerate(s):
  if i == 'A':
    A = index
  if i == 'Z':
    Z = index

print((Z - A) + 1)

Submission status: Wrong Answer

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

x = []

for i in range(n):
    if 'A' not in x and s[i] is 'A':
        x.append(i)
        x.append('A')
    elif 'A' in x and s[i] is 'Z':
        x.append(i)

print(x)
print(x[-1] - x[0] + 1)

Submission status: Wrong Answer

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

x = []

for i in range(n):
    if s[i] == 'A':
        x.append(i)
    elif s[i] == 'Z':
      x.append(i)
      
print(len(s[x[0]:x[1]]))

Submission status: Wrong Answer

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

x = []

for i in range(n):
    if s[i] == 'A':
        x.append(i)
    elif s[i] == 'Z':
      x.append(i)
      
print(x)
print(len(s[x[0]:x[1]]))

Submission status: Wrong Answer

Solution code:
s = str(input())
Alst = []
Zlst = []
for i in range(len(s)):
    if s[i]=='A':
        Alst.append(i)
    elif s[i]=='Z':
        Zlst.append(i)
print(max(Zlst)-min(Alst))

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] == 'A':
        ans -= i
        break

for j in range(n-1, 0):
    if s[j] == 'Z':
        ans += j
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
flag = False
for i in s:
    if i == 'A':
        flag = True
    if flag:
        ans += 1
    if i == 'Z':
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
L=[]

for i in range(len(S)):
    if S[i]=='A':
        L.append(S[i])
        for j in range(i+1,len(S)):
            L.append(S[j])
            if(S[j]=='Z'):
                for k in range(j+1,len(S)):
                    if S[k]=='Z':
                        L.append(S[j])
                    else:
                        print(len(L))
                        exit()

Submission status: Wrong Answer

Solution code:
S = 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
        break
print(num_last - num_first + 1)

Submission status: Wrong Answer

Solution code:
s=input()

print(len(s[s.index("A"):s.index("Z")+1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    S = list(input())
    s, g = -1, -1 
    for i in range(len(S)//2):
        if s < 0 and S[i] == 'A':
            s = i
        if g < 0 and S[-(i+1)] == 'Z':
            g = len(S)-i
    print(g-s)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(len(s)):
  if s[i]=="A":
    pA = i
for i in range(len(s)):
  if s[-i-1] == "Z":
    pZ = i
print(len(s)-pA-pZ-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

a = 10000
z = 0

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

print(z-a+1)

Submission status: Wrong Answer

Solution code:
import re

s = input()

result = re.search(r"A.*Z", s)
print(result.group(0))

Submission status: Wrong Answer

Solution code:
s = input()
list_s = list(s)

a_num = -1
z_num = -1

for i in range(len(s)):
    if list_s[i] == "A":
        a_num = i

    if list_s[i] == "Z":
        z_num = i

print(z_num - a_num + 1)

Submission status: Wrong Answer

Solution code:
s = input()

found_a = False
high = 0
low = 0

for index, word in enumerate(s):
    if found_a == False:
        if word == 'A':
            low = index
            found_a = True
    if word == 'Z':
        high = index

print(high - low)

Submission status: Wrong Answer

Solution code:
s = input()

found_a = True
high = 0
low = 0

for index, word in enumerate(s):
    if found_a == False:
        if word == 'A':
            low = index
            found_a = True
    if word == 'Z':
        high = index

print(high - low)

Submission status: Wrong Answer

Solution code:
S = input()
print(S.rindex("Z")-S.index("A"))

Submission status: Wrong Answer

Solution code:
s = input()

a_index = 0
z_index = 0
for i in range(len(s)):
    if s[i] == 'A' and a_index == 0:
        a_index = i
    elif s[i] == 'Z':
        z_index = i

print(z_index-a_index+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 reversed(range(len(S))):
    if(S[i] == "Z"):
        z = i
        break
az = S[a-1:z]
print(len(az))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = input()
count = 0
p = len(A)
min_=200000
max_=0
for i in range(p):
  if (A[i] == 'A'):
    min_ = min(i,min_)
    print(min_)
  if (A[i] == 'Z'):
    max_ = max(i,max_)
    print(max_)
print(max_-min_+1)

Submission status: Wrong Answer

Solution code:
s = input()

st = 0
ed = 0
for i in range(len(s)):
  if s[i] == "A":
    st = i
    break
for i in range(len(s)):
  if s[-i] == "Z":
    ed = -i + len(s)
    break
print(ed-st)

Submission status: Wrong Answer

Solution code:
s = input()
indexA = s.find("A")
indexZ = s.rfind("Z")
ans = s[indexA:indexZ + 1]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
A_index = None
Z_index = None
for i in  range(len(S)):
    if S[i] == "A":
        A_index = i
    elif S[i] == "Z":
        Z_index = i
print(len(S[A_index:Z_index+1]))

Submission status: Wrong Answer

Solution code:
s = input()
start = 0
stop = 0
for i in range(len(list(s))):
    if s[i] == "A":
        start = i
        break
for j in range(len(list(s))):
    if s[-j-1] == "Z":
        stop = -j-1
        break
print(len(list(s[start:stop+1])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print()
print(abs(S.find('A')-S.rfind('Z')))

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print(S.index('A'))
print(len(S)-(S[::-1].index('Z')+1))
print(abs(S.index('A')-(len(S)-(S[::-1].index('Z')+1)))+1)

Submission status: Wrong Answer

Solution code:
s = input()
length = range(0, len(s))
first_A = -1

for i in length:
    if s[i] == 'A':
        first_A = i
        break
    else:
        continue

last_Z = -1
for j in reversed(length):
    if s[j] == 'Z':
        last_Z = j
        break
    else:
        continue

max_diff = last_Z - first_A
print(max_diff)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 j in reversed(range(len(s))):
  if s[j]=='Z':
    G=s.index(s[j])
    break
print(G-S+1)

Submission status: Wrong Answer

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 j in reversed(range(len(s))):
  if s[j]=='z':
    G=s.index(s[j])
    break
print(G-S+1)

Submission status: Wrong Answer

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

Solution code:
string = input()
for i in range(len(string)):
    if string[i] == 'A':
        start=i
        break
for j in reversed(range(start+1, len(string))):
    if string[j]=='Z':
        end=j
        break
print(string[i:j+1])

Submission status: Wrong Answer

Solution code:
s = "HASFJGHOGAKZZFEGA"
min_A = len(s)
max_Z = 0
for i in range(len(s)):
    if s[i] == "A":
        if min_A>i:
            min_A = i
    if s[i] == "Z":
        if max_Z < i:
            max_Z = i
print(max_Z-min_A+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
top = 0
end = 0

while True:
    if S[count] == 'A':
        top = count
        break
    count += 1

count = -1
while True:
    if S[count] == 'Z':
        end = count
        break
    count -= 1

print(len(S[top:end + 1]))

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
top = 0
end = 0

while True:
    if S[count] == 'A':
        top = count
        break
    count += 1

count = -1
while True:
    if S[count] == 'Z':
        end = count
        break
    count -= 1

print(S[top:end + 1])

Submission status: Wrong Answer

Solution code:
s = input()
print(s[::-1].index("Z")-s.index("A")+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:
s = input()
cnt =0
f =[]
b= []
for i in range(len(s)):
  if s[i] =='A':
    f.append(i)
  for j in range(len(s)):
    if s[-j] =='Z':
      b.append(j)
print(abs((min(f)-1)- (len(s)-min(b))))

Submission status: Wrong Answer

Solution code:
s = input()
N = len(s)

left = None
right = 0
ans = 0
for i in range(N):
  if s[i] == "A":
    left = i
  elif s[i] == "Z":
    right = i
    if left != None:
      ans = max(ans, right-left+1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
string = input()

start = 0
end = 0
cnt = 0

for s in string:
    if s == 'A' and start == 0:
        start = cnt
  
    if s == 'Z':
        end = cnt
    
    cnt += 1
    
print(end - start + 1)

Submission status: Wrong Answer

Solution code:
string = input()

start = 0
end = 0
cnt = 0

for s in string:
  if s == 'A' and start != 0:
    start = cnt
  
  if s == 'Z':
    end = cnt
    
  cnt += 1

print(end - start + 1)

Submission status: Wrong Answer

Solution code:
s = input()
print(sorted(s,reverse = True).index('Z') - s.index('A') + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
count = 0
switch = 0
for i in s:
    if i == 'A':
        switch = 1
    elif i == 'Z':
        switch = 0
        count = 0
    if switch == 1:
        count += 1
    ans = max(ans,count)
print(ans+1)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
count = 0
switch = 0
for i in s:
    if i == 'A':
        switch = 1
    elif i == 'Z':
        switch = 0
    if switch == 1:
        count += 1
    ans = max(ans,count)
print(ans+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 == 0:
        a = i 
    if s[i] == 'Z':
        z = i 
ans = z - a + 1
if len(s) < 1:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
if len(s) == 1:
    print(0)
else:
    first_A_index = 0
    last_Z_index = 0
    for i, c in enumerate(s):
        if c == 'A' and first_A_index == 0:
            first_A_index = i
        elif c == 'Z':
            last_Z_index = i
    print(last_Z_index - first_A_index + 1)

Submission status: Wrong Answer

Solution code:
s = input()
first_A_index = 0
last_Z_index = 0
for i, c in enumerate(s):
    if c == 'A' and first_A_index == 0:
        first_A_index = i
    elif c == 'Z':
        last_Z_index = i
print(last_Z_index - first_A_index + 1)

Submission status: Wrong Answer

Solution code:
s = input()
a = s.index('A')
z = s.index('Z')
print(s[a:z+1])

Submission status: Wrong Answer

Solution code:
s = input()

CA = s.index('A')
CZ = s.rindex('Z') 
L = len(s)

print(L-CA-CZ+2)

Submission status: Wrong Answer

Solution code:
s = input()

CA = s.index('A')
CZ = s.rindex('Z') 
L = len(s)

print(L-CA-CZ+5)

Submission status: Wrong Answer

Solution code:
s = input()

CA = s.index('A')
CZ = s.rindex('Z') 
L = len(s)

print(L-CA-CZ+8)

Submission status: Wrong Answer

Solution code:
s = input()

CA = s.index('A')
CZ = s.rindex('Z') 
L = len(s)

print(L-CA-CZ)

Submission status: Wrong Answer

Solution code:
s=input()

mojiA=s.index("A")
mojiZ=s.index("Z")

d=s[mojiA:mojiZ+1]

print(len(d))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(input())
s1 = s[::-1]
li = []
for i in range(len(s)):
    if s[i] == "A":
        li.append(i+1)
for i in range(len(s1)):
    if s1[i] == "Z":
        li.append(i+1)
print(len(s)-li[1]+1-li[0]+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def _index(l, c):
    if c in l:
        return l.index(c)
    else:
        return -1

chars = list(input())

a = _index(chars, "A")
z = _index(list(reversed(chars)), "Z")

if a == -1 or z == -1:
    print("0")
    exit(0)

if a < z:
    print(len(chars) - a - z)
else:
    print("0")

Submission status: Wrong Answer

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

chars = list(input())

should_count = False
counter = 0
lengths = []

for i in range(len(chars)):
    if chars[i] == "A" and not should_count:
        should_count = True
        counter = 0
    if should_count:
        counter += 1
    if chars[i] == "Z" and should_count:
        is_last_char = i == len(chars) - 1
        if is_last_char or not chars[i + 1] == "Z":
            should_count = False
            lengths.append(counter)

print(max(lengths))

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
for i in s:
  if i=='A':
    a=s.index(i)
    break
for t in s:
  if t=='Z':
    b=s.index(t)
print(b-a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
mojiretsu = ""
k = []
ans = []
for i in range(len(s)):
    if s[i] == "A":
        for j in range(i,len(s)):
            mojiretsu += s[j]
            if s[j] == "Z":
                k.append(mojiretsu)
                mojiretsu = ""
                break
for i in range(len(k)):
    ans.append(len(k[i]))
print(max(ans))

Submission status: Wrong Answer

Solution code:
S = list(input())
num = 0
num2 = 0
for i in range(len(S)):
    if S[i] == "A":
        num = i
        break
for i in range(len(S)):
    if S[i] == "Z":
        num2 = i
        
print(num2 - num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
a=s.index("A")
b=s.rfind("z")
print(s[a:b+1])

Submission status: Wrong Answer

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