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:
Strings = input()

for i in range(0,len(Strings)):
    if Strings[i] == "A":
        length = i
        print(i)
        break

for i in range(len(Strings))[::-1]:
    if Strings[i] == "Z":
        length2 = i
        print(i)
        break

print(length2 - length +1 )

Submission status: Wrong Answer

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

for i in range(len(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: Wrong Answer

Solution code:
s = input()

ansMax = 0
for i in range(len(s)):
    if s[i] == 'A':
        cnt = 1
        for j in range(i + 1, len(s)):
            if s[j] == 'Z':
                if j == (len(s) - 1):
                    cnt += 1
                    ansMax = max(ansMax, cnt)
                    break
                elif s[j + 1] == 'Z':
                    cnt += 1
                else:
                    cnt += 1
                    ansMax = max(ansMax, cnt)
                    break
            else:
                cnt += 1

print(ansMax)

Submission status: Wrong Answer

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-min+1)

Submission status: Wrong Answer

Solution code:
s = input()
apos = 0
zpos = 0

for i, c in enumerate(s):
  if c == "A" and apos == 0:
    apos = i
  if c == "Z":
    zpos = i
    
print(zpos - apos + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s=list(input().split())
a=200000
z=0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = list(input())
count = 0
for num in s :
  if num == "A":
    index1 = s.index(num)
    break
  else :
    continue
    
for num in s[index1:]:
  if num == "Z":
    break
  else :
    count += 1

print(count + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
start = s.find("A")
end = s[start:].find("Z")
print(end - start + 1)

Submission status: Wrong Answer

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

Solution code:
import sys
from collections import defaultdict
operaciones = list()
p=0
y=0
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(str,c))
list(c)
x = c[0]
a =list(x)
if "A" in a:
  l = a.index("A")
aux = defaultdict(list)
for index, item in enumerate(a):
    aux[item].append(index)
result = {item: indexs for item, indexs in aux.items() if len(indexs) > 0}
for llave,valor in result.items():
  if llave == "A":
    d = valor
  elif llave == "Z":
    pp = valor  
minimo=min(d)
min1 = min(pp)
for k in range(len(pp)-1):
  if pp[k+1]-pp[k] == 1:
      y+=1
      x = pp[k+1]
if y >0: 
  GH=a[minimo:x+y]
  v = len(GH)
  print(v)
  sys.exit()  

if min1<minimo:
  for l in range(len(pp)-1):
    if pp[l+1]- pp[l] == 1:
      y+=1
      x = pp[l+1]
if y >0: 
  GH=a[minimo:x+y]
  sys.exit()    
if min1 < minimo:
  maximo = max(pp)
  gh = a[minimo:maximo+1]
  print(len(gh))
  sys.exit()
gh = a[minimo:min1+1]
print(len(gh))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
operaciones = list()
p=0
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(str,c))
list(c)
x = c[-1]
a =list(x)
if "A" in a:
  l = a.index("A")
aux = defaultdict(list)
for index, item in enumerate(a):
    aux[item].append(index)
result = {item: indexs for item, indexs in aux.items() if len(indexs) > 0}
for llave,valor in result.items():
  if llave == "A":
    d = valor
  elif llave == "Z":
    pp = valor  
minimo=min(d)
min1 = min(pp)
for l in range(len(pp)-1):
  if pp[l+1]- pp[l] == 1:
    min1+=1
    
if min1 < minimo:
  maximo = max(pp)
  gh = a[minimo:maximo+1]
  print(len(gh))
  sys.exit()
gh = a[minimo:min1+1]
print(len(gh))

Submission status: Wrong Answer

Solution code:
s=input()
can=0
mayor=0
for i in range(len(s)):
  can=0
  if s[i]=="A":
    posicion=i
    a=len(s[posicion:])
    for i in range(len(s)-posicion):
      posicion2=i+posicion
      #print(s[i])
      if s[i+posicion]=="Z":
        
        if posicion2==a:
          can+=1
          break
        else:
          for i in range(len(s)-posicion2):   
            if s[i+posicion2]=="Z":          
              can+=1
            else:
              break
        break 
      #elif s[i+posicion]=="Z":
        #can+=1
        #break
      elif i+posicion==len(s)-1 and s[i+posicion]!="Z":
        can=0
      else:
        can+=1
  
  if can>mayor:
    mayor=can
print(mayor)
'''
a=len(s[posicion:])

for i in range(len(s)-posicion):
  posicion2=i+posicion
  #print(s[i])
  if s[i+posicion]=="Z":
    if posicion2==a:
      can+=1
      break
    else:
      for i in range(len(s)-posicion2):   
        if s[i+posicion2]=="Z":          
          can+=1
        else:
          break
    break 
  #elif s[i+posicion]=="Z":
    #can+=1
    #break
  elif i+posicion==len(s)-1 and s[i+posicion]!="Z":
    can=0
  else:
    can+=1
print(can)
'''

Submission status: Wrong Answer

Solution code:
s=input()
can=0
for i in range(len(s)):
  if s[i]=="A":
    posicion=i
    break
a=len(s[posicion:])

for i in range(len(s)-posicion):
  posicion2=i+posicion
  #print(s[i])
  if s[i+posicion]=="Z":
    if posicion2==a:
      can+=1
      break
    else:
      for i in range(len(s)-posicion2):   
        if s[i+posicion2]=="Z":          
          can+=1
        else:
          break
    break 
  #elif s[i+posicion]=="Z":
    #can+=1
    #break
  elif i+posicion==len(s)-1 and s[i+posicion]!="Z":
    can=0
  else:
    can+=1
print(can)

Submission status: Wrong Answer

Solution code:
s=input()
can=0
for i in range(len(s)):
  if s[i]=="A":
    posicion=i
    break
a=len(s[posicion:])

for i in range(len(s)-posicion):
  posicion2=i+posicion
  #print(s[i])
  if s[i+posicion]=="Z":
    if posicion2==a:
      can+=1
      break
    else:
      for i in range(len(s)-posicion2):   
        if s[i+posicion2]=="Z":          
          can+=1
        else:
          break
    break 
  #elif s[i+posicion]=="Z":
    #can+=1
    #break
  elif s[i+posicion]==len(s)-1 and s[i+posicion]!="Z":
    can=0
  else:
    can+=1
print(can)

Submission status: Wrong Answer

Solution code:
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']

print(max(index_Z) - s.index('A'))

Submission status: Wrong Answer

Solution code:
s=input()
t=[200000,-200000]
for i in range(len(s)//2+1):
    if s[i]=="A" and t[0]==200000:
        t[0]=i
    if s[-i-1]=="Z" and t[1]==-200000:
        t[1]=i
print(len(s)-t[1]-t[0])

Submission status: Wrong Answer

Solution code:
import sys, re
input = sys.stdin.readline

pattern = re.compile('A.*?Z')
ans = 2 ** 18

s = input()

for m in pattern.findall(s):
  length = len(m)
  if length < ans:
    ans = length
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
input = sys.stdin.readline

pattern = re.compile('A.*?Z')
ans = 65536

s = input()

for m in pattern.findall(s):
  length = len(m)
  if length < ans:
    ans = length
    
print(ans)

Submission status: Wrong Answer

Solution code:
word = list(input())
ans = ''
a = []
for i in range(len(word)):
  if word[i] == 'A':
    for j in range(i, len(word)):
      ans += word[j]
      if word[j] == 'Z':
        a.append(len(ans))
        ans = ''
print(max(a))

Submission status: Wrong Answer

Solution code:
word = list(input())
ans = ''
for i in range(len(word)):
  if word[i] == 'A':
    for j in range(i, len(word)):
      ans += word[j]
      if word[j] == 'Z':
        print(len(ans))
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
ai, zi = 0, 0
for i in range(len(s)):
    if ai == 0 and s[i] == 'A':
        ai = i

    if s[i] == 'Z':
        zi = i

print(zi - ai + 1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
s = (stdin.readline().rstrip())
A = 10**9
Z = -10**9
for ind,i in enumerate(s):
    if i == "A" and ind < A:
        A = ind
    if i == "Z" and ind > Z:
        A = ind
print(Z-A+1)

Submission status: Wrong Answer

Solution code:
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i
    elif s == 'Z':
        max_Z = i

print(max_Z - min_A + 1)

Submission status: Wrong Answer

Solution code:
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i
    elif s == 'Z':
        max_Z = i

print(max_Z - min_A)

Submission status: Wrong Answer

Solution code:
s=input()

print(s.find('Z')-s.find('A')+1)

Submission status: Wrong Answer

Solution code:
row = input().split()
s = list(row[0])
Flag = 0
count = 0
for i in range(len(s)):
    if s[i] == 'A':
        Flag = 1
    if s[i] == 'Z':
        Flag = 0

    if Flag == 1:
        count += 1

print(count+1)

Submission status: Wrong Answer

Solution code:
s = input()
first = 0
last = 0
for i in range(0,len(s)):
    if s[i] == "A" and first == 0:
        first = i
    if s[i] == "Z":
        last = i
print(int(last - first + 1))

Submission status: Wrong Answer

Solution code:
a = input()
b = 0
c = 0
d = False
for i in a:
     if i == "A" and b == 0:
           d = True
           b += 1
     if d == True:
          c += 1
     if i == "Z":
          d = False
          b = 0
print(c)

Submission status: Wrong Answer

Solution code:
a = input()
b = 0
c = 0
d = False
f = []
for i in a:
     if i == "A"and b == 0:
           d = True
           b += 1
     if d == True:
          c += 1
     if i == "Z":
          d = False
          b = 0
          f.append(c)
          c = 0
print(max(f))

Submission status: Wrong Answer

Solution code:
a = input()
b = 0
c = 0
d = False
for i in a:
     if i == "A" and b == 0:
           d = True
           b += 1
     if d == True:
          c += 1
     if i == "Z":
          d = False
print(c)

Submission status: Wrong Answer

Solution code:
a = input()
b = 0
c = 0
d = False
for i in a:
     if i == "A" and b == 0:
           d = True
     if d == True:
          c += 1
     if i == "Z":
          d = False
print(c)

Submission status: Wrong Answer

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

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

print(cnt+1)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

Solution code:
#文字列を取得する(QWERTYASDFZXCV)
strings = list(input())

#Aの一番小さいインデックス番号
place_smallest_A= 1000
place_largest_Z= 0

#for文で一番小さいインデックスのAを取り出す
for number in range(len(strings)):
  if strings[number] == "A":
    if number < place_smallest_A:
      place_smallest_A = number
      
#for文で一番大きいインデックスのZを取り出す
for number in range(len(strings)):
  if strings[number] == "Z":
    if number > place_smallest_A:
      place_smallest_Z = number

#A~Zの間でスライスする
ans = strings[place_smallest_A:place_smallest_Z+1]
#配列の長さを答える
print(len(ans))

Submission status: Wrong Answer

Solution code:
#文字列を取得する(QWERTYASDFZXCV)
strings = list(input())

#Aの位置をさがす
place_A = strings.index("A")
#Zの位置を探す
place_Z = strings.index("Z")

#A~Zの間でスライスする
ans = strings[place_A:place_Z+1]
#配列の長さを答える
print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
S = list(S)
l = []
ans = ''
l_str = ''
for i in range(len(S)-1):
    if S[i] == 'A':
        for j in range(len(S)-1):
            l.append(S[i])
            if S[i] == 'Z':
                l_str = ''.join(l)
                if l_str > ans:
                    ans = l_str
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

A_index = s.find("A")
Z_index = s.rfind("Z")
print(s[A_index:Z_index + 1])

Submission status: Wrong Answer

Solution code:
s = 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-1]=="Z":
        z = len(s)-i-1

print(z-a+1)

Submission status: Wrong Answer

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

b = S.find('Z')

print(len(S)-a-b)

Submission status: Wrong Answer

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

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

s = s[::-1]
print(s)

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

Submission status: Wrong Answer

Solution code:
s=input()
flag1=0
flag2=0

for i in range(len(s)):
    if s[i]=='A' and flag1==0:
        start=i
        flag1=1
    elif s[i]=='Z' and flag1==1 and flag2==0:
        flag2=1
        finish=i

print(finish-start+1)

Submission status: Wrong Answer

Solution code:
s = input()

idx_a = 0
idx_b = 0

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

print(idx_b - idx_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 = list(input())
st = 0
ed = 0
for i in range(len(S)):
    if (S[i] == 'A'):
        st = min(i, st)
        print(S[i], i, st)
    if (S[i] == 'Z'):
        ed = i
        print(S[i], i, ed)
ans = ed - st + 1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
st = 0
ed = 0
for i in range(len(S)):
    if S[i] == 'A' and st == 0:
        st = i
    if S[i] == 'Z' and i > ed:
        ed = i
ans = ed - st + 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

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

Solution code:
s = input()
aind = 0
for i , c in enumerate(s[::-1]):
  if c == "A":
    aind =  i
zind = 0
for i,c in enumerate(s):
  if c == "Z":
    zind = i
    
print(zind-aind)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input()
print(len(S[S.index("A"):S.index("Z")+1]))

Submission status: Wrong Answer

Solution code:
s = input()
start = 0
end = 0
flag1 = True
flag2 = True
for i in range(len(s)):
    if s[i] == "A" and flag1 == True:
        start = i
        flag1 = False
    elif s[i] == "Z" and start != 0 and flag2 == True:
        end = i
        flag2 = False
slNnm = (end + 1) - start
print(slNnm)

Submission status: Wrong Answer

Solution code:
s = input()
start = 0
end = 0
flag1 = True
flag2 = True
for i in range(len(s)):
    if s[i] == "A" and flag1 == True:
        start = i
        flag1 = False
    elif s[i] == "Z" and start != 0 and flag2 == True:
        end = i
        flag = False
slNnm = (end + 1) - start
print(slNnm)

Submission status: Wrong Answer

Solution code:
s = input()
num_A = 0
num_Z = 0
for ind,i in enumerate(s):
  if(num_A == 0 and i == 'A'):
    num_A = ind
  if(i == 'Z'):
    num_Z = ind
print(num_Z - num_A + 1)

Submission status: Wrong Answer

Solution code:
s = input()
num_A = 0
num_B = 0
for ind,i in enumerate(s):
  if(num_A == 0 and i == 'A'):
    num_A = ind
  if(i == 'Z'):
    num_Z = ind
print(num_B - num_A + 1)

Submission status: Wrong Answer

Solution code:
s=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":
        z=i
print(z-a+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

sub = 0

for i in range(len(s)):
    if s[i] == "A":
        for j in range(i+1,len(s)):
            if s[j]=="Z":
                sub = j-i+1

print(sub)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 入力
s=input()

# 'A'と'Z'の位置を保存する変数
a=z=-1

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

# 出力
print(z-a+1)

Submission status: Wrong Answer

Solution code:
# 入力
s=input()

# 'A'と'Z'の位置を保存する変数
a=z=0

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

# 出力
print(z-a+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

substr = "" 
for i in range(N):
  if s[i] == "A":
    substr = s[i:]
    break

index = substr.rfind("Z")
ans = len(substr[:index])
print(ans)

Submission status: Wrong Answer

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

substr = "" 
for i in range(N):
  if s[i] == "A":
    substr = s[i:]
    break

index = substr.rfind("Z")
print(substr[:index])

Submission status: Wrong Answer

Solution code:
import math
s = input()
a_found = z_found = False
az_len = len(s)
for i in range(math.ceil(len(s)/2) + 1):
    if s[i] == 'A':
        a_found = True
    elif not a_found:
        az_len -= 1
    if s[-i-1] == 'Z':
        z_found = True
    elif not z_found:
        az_len -= 1
    if a_found and z_found:
        break
print(az_len)

Submission status: Wrong Answer

Solution code:
import math
s = input()
a_found = z_found = False
az_len = len(s)
for i in range(math.ceil(len(s)/2)):
    if s[i] == 'A':
        a_found = True
    elif not a_found:
        az_len -= 1
    if s[-i-1] == 'Z':
        z_found = True
    elif not z_found:
        az_len -= 1
    if a_found and z_found:
        break
print(az_len)

Submission status: Wrong Answer

Solution code:
s=input()
pos1=0
pos2=0
flag1=False
flag2=False
for i in range(len(s)):
  if s[i]=='A' and flag1==False:
    pos1=i+1
    flag1=True
  if s[-i]=='Z' and flag2==False:
    pos2=len(s)-i+1
    flag2=True
print(pos2-pos1+1)

Submission status: Wrong Answer

Solution code:
s=input()
pos1=0
pos2=0
flag1=False
flag2=False
for i in range(len(s)):
  if s[i]=='A' and flag1==False:
    pos1=i+1
  if s[-i]=='Z' and flag2==False:
    pos2=len(s)-i+1
print(pos2-pos1+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
index = []
for i, c in enumerate(s):
    if c == "A":
        index.append(i)
        break

for i, c in enumerate(reversed(s)):
    if c == "Z":
        index.append(len(s)-i)
        break

count = len(s[index[0]:index[1]])

Submission status: Wrong Answer

Solution code:
s = input()
index = []
for i, c in enumerate(s):
    if c == "A":
        index.append(i)
        break

for i, c in enumerate(reversed(s)):
    if c == "Z":
        index.append(i)
        break

count = len(s[index[0]:-index[1]])
print(count)

Submission status: Wrong Answer

Solution code:
def a2z_string(s: str)->int:
    a = s.find('a')
    z = s.rfind('z')
    return z - a + 1


if __name__ == "__main__":
    s = input()
    ans = a2z_string(s)
    print(ans)

Submission status: Wrong Answer

Solution code:
N=list(input())
N_num=len(N)



for i in range(N_num):
        if N[i] == "A":
                min_num=i
                break

N.reverse()
for i in range(N_num):
        if N[i] == "Z":
                max_num=i
                break

print(N_num-max_num-min_num+1)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
x = I()
if x < 1200:
    print("ABC")
else:
    print("ARC")
"""
#B
s = input()
n = len(s)
for i in range(n):
    if s[i] == "A":
        for j in range(i+1,n):
            if s[j] == "Z":
                print(j-i+1)
                quit()
#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
s = list(input())
r = list(reversed(s))

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

Submission status: Wrong Answer

Solution code:
s = list(input())
r = list(reversed(s))

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

Submission status: Wrong Answer

Solution code:
s = list(input())
r = list(reversed(s))

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

Submission status: Wrong Answer

Solution code:
s = list(input())
r = list(reversed(s))

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

Submission status: Wrong Answer

Solution code:
s = list(input())
r = list(reversed(s))

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

Submission status: Wrong Answer

Solution code:
s = list(input())
r = list(reversed(s))

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

Submission status: Wrong Answer

Solution code:
s = input()
a = z =  ''
for i, v in enumerate(s):
    if not a:
        if v == 'A':
            a = i
    if not z:
        if s[len(s) - i -1] == 'Z':
            z = len(s) - i
            
    if a and z:
        print(z - a)
        exit()

Submission status: Wrong Answer

Solution code:
s = input()
a = z =  ''
for i, v in enumerate(s):
    if (not a) and (v == 'A'):
            a = i
    if (not z) and (s[len(s) - i -1] == 'Z'):
            z = len(s) - i
            
    if a and z:
        print(z - a)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = input()

a = 0
z = 0

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

for i in range(len(x)):
    if x[-(i+1)] == "Z":
        z = len(x) - i
        break

print(x[a:z])

Submission status: Wrong Answer

Solution code:
s=list(input())
x=s.index('A')
t=sorted(s)
y=t.index('Z')
print(len(s)-x-y)

Submission status: Wrong Answer

Solution code:
s = list(map(str, input()))

r = []
val = 0
for char in s:
    if char == 'A':
        if val == 0:
            val += 1
        else:
            val = 0
    if char == 'Z':
        val = 0
    r.append(val)
print(r.count(1) + 1)

Submission status: Wrong Answer

Solution code:
# ABC 053 B
s =str(input())
min_A = 0
max_Z = 0
for i,j in enumerate(s):
    if j =="A" and min_A ==0:
        min_A =i
    if j == "Z":
        max_Z =i
if max_Z == min_A:
    ans = 0
else:
    ans = max_Z - min_A + 1
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC 053 B
s =str(input())
min_A = 0
max_Z = 0
for i,j in enumerate(s):
    if j =="A" and min_A ==0:
        min_A =i
    if j == "Z":
        max_Z =i
print(max_Z - min_A + 1)

Submission status: Wrong Answer

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

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,0,-1):
    if S[i] == 'Z':
        z_index = i
        break

print(N - z_index - a_index)