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: Accepted

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(abs(S.index('A')-(len(S)-(S[::-1].index('Z')+1)))+1)

Submission status: Accepted

Solution code:
#2019/10/24
s = open(0).read()
# print(s)
index_A = []
index_Z = []
for index, char in enumerate(list(s)):
    if char == "A":
        index_A.append(index)
    if char == "Z":
        index_Z.append(index)
print(max(index_Z) - min(index_A)+1)

Submission status: Accepted

Solution code:
S = input()
first = 0
last = 0

for i in range(0, len(S)):
    if S[i] == 'A':
        first = i
        break

for i in range(len(S)-1, -1, -1):
    if S[i] == 'Z':
        last = i
        break

print(last - first + 1)

Submission status: Accepted

Solution code:
S = input()
first = 0
last = 0

for i in range(0, len(S)):
    if S[i] == 'A':
        first = i
        break

S = S[::-1]

for i in range(0, len(S)):
    if S[i] == 'Z':
        last = i
        break

print(len(S) - first - last)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list()
z = list()

s = input()

for i in range(len(s)):
    if(s[i]=='A'):
        a.append(i)
    elif(s[i]=='Z'):
        z.append(i)
        
aa = min(a)
zz = max(z)

#print(a,z)

if(len(a)==0 or len(z)==0):
    print(0)
elif(aa<zz):
    print(zz-aa+1)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
id1 = s.index("A")
lists = list(s)
lists.reverse()
id2 = lists.index("Z")
print((len(s)-id2) - id1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

si = 0
while s[si] != 'A':
    si += 1

ei = len(s) - 1
while s[ei] != 'Z':
    ei -= 1

ans = ei - si + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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 list(reversed(length)):
    if s[j] == 'Z':
        last_Z = j
        break
    else:
        continue

max_diff = last_Z - first_A
print(max_diff + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

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

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


print(end-fst+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
s1=s[::-1]
ind1=s.index('A')
for i in range(len(s)-1,-1,-1):
    if s[i]=='Z':
        ind2= i 
        break 
print(ind2-ind1+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

z = -1
for i, c in enumerate(s):
    if c == 'Z':
        z = i

a = len(s) + 1
for i, c in enumerate(s):
    if c == 'A':
        a = i
        break

print(z - a + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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(len(string[i:j+1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    s=input()
    t=0
    while s[t]!='A':
        t+=1
    b=-1
    while s[b]!='Z':
        b-=1
    print(len(s[t:b])+1)
resolve()

Submission status: Accepted

Solution code:
s = input()

print(s.rfind("Z")-s.find("A")+1)

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
import re
s = str(input())

a_to_z = re.findall('A(.*)Z', s)

print(len(a_to_z[0])+2)

Submission status: Accepted

Solution code:
text = input()
A_index = -1
Z_index = -1
for i in range(len(text)):
  if text[i] == 'A' and A_index == -1:
    A_index = i
  if text[i] == 'Z':
    Z_index = i
    
print(Z_index - A_index + 1)

Submission status: Accepted

Solution code:
s = input()

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

for i in range(len(s)-1, -1, -1):
    if s[i] == 'Z':
        z = i
        break

print(z-a+1)

Submission status: Accepted

Solution code:
s = input()
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: Accepted

Solution code:
s = input()

i_A = 0
i_Z = 0
for i in range(len(s)):
  if s[i] == 'A':
    i_A = i
    break

for i in range(len(s)-1, -1, -1):
  if s[i] == 'Z':
    i_Z = i
    break

print(i_Z-i_A+1)

Submission status: Accepted

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[i] == 'Z':
    z=i
print(z-a+1)

Submission status: Accepted

Solution code:
s = input()

for i in range(len(s)):
    if s[i] == 'A':
        no_A = i
        break
for j in reversed(range(len(s))):
    if s[j] == 'Z':
        no_Z = j
        break
print(no_Z - no_A + 1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
x = list(input())
y = list(reversed(x))
a = x.index("A")
z = y.index("Z")
l = len(x)
print(l-a-z)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

index_a = 0
index_z = 0

for i, a in enumerate(s):
    if a == 'A':
        index_a = i
        break

length = len(s)
for i, a in enumerate(reversed(s)):
    if a == 'Z':
        index_z = length - 1 - i
        break

print(index_z - index_a + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(reversed(s))
a=s.index("A")
z=t.index("Z")
l=len(s)
print(l-a-z)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    print(len(s[s.index("A"):s.rindex("Z") + 1]))


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
s=input()
for num,moji in enumerate(s):
    if moji == "A":
        a_num=num
        break

rev_s=s[::-1]
for num,moji in enumerate(rev_s):
    if moji == "Z":
        z_num = num
        break
ans = (len(s)-z_num)-a_num
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
min_a = 200001
max_z = 0
for i, one_s in enumerate(s):
  if one_s == "A":
    if i < min_a:
      min_a = i
  elif one_s == "Z":
    if i > max_z:
      max_z = i
print(max_z - min_a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
first = -1
last = -1
for i,c in enumerate(S):
  if c == "A":
    first = i
    break
for i,c in enumerate(S):
  if c == "Z"  :
    last = i
print(last - first + 1)

Submission status: Accepted

Solution code:
s = list(input())
a_ix = s.index('A')
z_ix = len(s) - list(reversed(s)).index('Z')
print(z_ix - a_ix)

Submission status: Accepted

Solution code:
s=list(input())

As=[i for i, x in enumerate(s) if x == 'A']
Zs=[i for i, x in enumerate(s) if x == 'Z']
print(Zs[-1]-As[0]+1)

Submission status: Accepted

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

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

Submission status: Accepted

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) - 1, -1, -1):
    if s[i] == "Z":
        z = i
        break
print(len(s[a:z+1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(len(s[s.index('A'):(len(s)-s_inv.index('Z'))]))

Submission status: Accepted

Solution code:
s = input()
lenS = len(s)
a = z = -1

for i in range(lenS):
    if s[i] == 'A':
        a = i
        break

for i in range(lenS-1, -1, -1):
    if s[i] == 'Z':
        z = i
        break

print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
a=s.index('A')
b=[i for i, x in enumerate(s) if x == "Z"]
print(b[-1]-a+1)

Submission status: Accepted

Solution code:
s=input()
alist=[]
zlist=[]
for _ in range(len(s)):
  if s[_]=='A':
    alist.append(_)
  elif s[_]=='Z':
    zlist.append(_)
print(max(zlist)-min(alist)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
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
        break
print(Z-A)

Submission status: Accepted

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

Submission status: Accepted

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

s = list(input().strip())

a = 0
z = len(s)

for i in s:
    if 'A' == i:
        break
    a += 1

for i in reversed(s):
    if 'Z' == i:
        break
    z -= 1

print(z - a)

Submission status: Accepted

Solution code:
s = input().rstrip()
ss = s[::-1]
n = len(s)
res = 0
for i in range(n):
    if s[i] == 'A':
        res -= i - 1
        break
for i in range(n):
    if ss[i] == 'Z':
        res += n - 1 - i
        break
print(res)

Submission status: Accepted

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 + 1
        break
    count -= 1

if end == 0:
    print(len(S[top:]))
else:
    print(len(S[top:end]))

Submission status: Accepted

Solution code:
s = input()
N = len(s)
flag0 = 0
flag1 = 0
A = float("inf")
Z = -float("inf")
for i in range(N):
    t1 = s[i]
    t2 = s[N-1-i]
    if t1 == "A" and flag0 == 0:
        A = i
        flag0 = 1
    if t2 == "Z" and flag1 == 0:
        Z = N-1-i
        flag1 = 1
print(max(0,Z-A+1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A=[]
Z=[]

for i in range(N):
  if S[i]=="A":
    A.append(i)
  if S[i]=="Z":
    Z.append(i)
#print(A)
#print(Z)

print(Z[-1]-A[0]+1)

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')




S=input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

a=s.find("A")
z=len(s)-s[::-1].find("Z")-1
print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
first = last = None
for i, c in enumerate(s):
    if c == 'A' and first is None:
        first = i
    if c == 'Z':
        last = i
print(len(s[first:last+1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
cnt = 0

cnt = s.rfind('Z') - s.find('A') + 1

print(cnt)

Submission status: Accepted

Solution code:
S = list(input())

a = S.index('A')
for i in range(len(S)):
    if S[i] == 'Z':
        z = i

print (z - a + 1)

Submission status: Accepted

Solution code:
S = input()
i = 0
start = 0
while True:
    if S[i] == "A":
        start = i
        break
    i += 1

i = -1
end = 0
while True:
    if S[i] == "Z":
        end = i + 1
        break
    i -= 1

if end < 0:
    print(len(S[start:end]))
else:
    print(len(S[start:]))

Submission status: Accepted

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

def main():
    s = input().strip()

    l = 0
    while l < len(s):
        if s[l] == "A":
            break
        l += 1
    r = len(s)-1
    while r >= 0:
        if s[r] == "Z":
            break
        r -= 1
    
    print(r-l+1)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ind_A = s.index("A")
ind_Z = len(s) - s[::-1].index("Z") - 1

# print(ind_A)
# print(ind_Z)

print(ind_Z - ind_A + 1)

Submission status: Accepted

Solution code:
s = list(input())

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

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

print(end - start + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

# print(s)
n1 = s.index('A')
# print(n1)
# s = s[n:]

# print(s)
n2 = s.rindex('Z')
# n2 = len(s) - n2 - 1
# print(n2)
# s = s[:n + 1]

print(n2 - n1 + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

i = 0
while True:
    if s[i] == 'A':
        A_index = i
        break
    i += 1
j = len(s) - 1
while True:
    if s[j] == 'Z':
        Z_index = j
        break
    j -= 1

print(j - (i - 1))

Submission status: Accepted

Solution code:
s = input()
start_flag = 0
for i in range(len(s)):
  if s[i] == 'A' and not start_flag:
    start = i
    start_flag = 1
  elif s[i] == 'Z':
    finish = i
ans = finish - start + 1
print(ans)

Submission status: Accepted

Solution code:
s = input()

if s[::-1].index('Z') !=0:
  print( len(s[s.index('A'):-s[::-1].index('Z')]))
else:
  print(len(s[s.index('A'):]))

Submission status: Accepted

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]=='Z':
        z = i
if z > a:
    print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
string = input()

start = 0
end = 0
cnt = 0
flg = False

for s in string:
    if s == 'A' and flg == False:
        start = cnt
        flg = True
  
    if s == 'Z':
        end = cnt
    
    cnt += 1

print(end - start + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
S = list(s)

for i in range(len(S)):
    if S[i] == 'A':
        first_A = i
        break
for i in range(len(S)):
    if S[-(i+1)] == 'Z':
        last_Z = len(S) - i
        break
        
ans = last_Z - first_A
print(ans)

Submission status: Accepted

Solution code:
S = input()

def AtoZ(s):
    for front in range(0,len(s)):
        if s[front] == "A":
            break
    for back in range(0,len(s))[::-1]:
        if s[back] == "Z":
            break
    ans = back - front + 1
    return ans

ans = AtoZ(S)
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
a = [i for i, x in enumerate(s) if x == 'A']
z = [i for i, x in enumerate(s) if x == 'Z']
print(z[-1]-a[0]+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
n = len(s)
Aindex = s.index("A")
s = list(reversed(s))
Zindex = s.index("Z")
print(n-Aindex-Zindex)

Submission status: Accepted

Solution code:
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
f = False
place_a = len(s)
place_z = 0
for i in range(len(s)):
    if s[i] == "A":
        place_a = min(place_a,i)
    if s[i] == "Z":
        place_z = max(place_z,i)
print(place_z-place_a+1)

Submission status: Accepted

Solution code:
s = input()
index_a=-1
for i in range(len(s)):
    if s[i]=="A":
        index_a = i
        break
j=len(s)-1
index_z=-1
while j>0:
    if s[j]=="Z":
        index_z = j
        break
    j-=1
print(index_z-index_a+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

A = s.index("A") + 1
Z = s.rindex("Z") + 1

print(Z - A + 1)

Submission status: Accepted

Solution code:
s = input()

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


print(CZ-CA+1)

Submission status: Accepted

Solution code:
s=input()

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

d=s[mojiA:mojiZ+1]

print(len(d))

Submission status: Accepted

Solution code:
s = input()

for i,ch in enumerate(s):
  if ch=='A':
    idx_1 = i
    break
  
for i,ch in enumerate(s[::-1]):
  if ch=='Z':
    idx_2 = len(s) - i - 1
    break
    
print(idx_2 - idx_1 + 1)

Submission status: Accepted

Solution code:
s = input()
le = len(s)
list_a = []
list_z = []
dif = 0
for i in range(le):
	if s[i] == 'A':
		list_a.append(i)
	elif s[i] == 'Z':
		list_z.append(i)
print(int(list_z[-1])-int(list_a[0])+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

ans_a=1145151919
ans_z=0
for i in range(len(s)):
    if s[i]=='A':
        ans_a=min(ans_a,i)
    elif s[i]=='Z':
        ans_z=max(ans_z,i)
print(ans_z-ans_a+1)

Submission status: Accepted

Solution code:
s = input()

for start, c in enumerate(s):
    if c == 'A':
        s = s[start:]
        break
for end, c in enumerate(s[::-1]):
    if c == 'Z':
        s = s[:len(s) - end]
        break

print(len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l=0
r=len(s)-1
fl=True
fr=True
while fl or fr:
    if fl:
        if s[l]=='A':
            fl=False
        else:
            l+=1
    
    if fr:
        if s[r]=='Z':
            fr=False
        else:
            r-=1
print(r-l+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    As = []
    Zs = []
    for i in range(len(s)):
        if s[i] == "A":
            As.append(i)
        elif s[i] == "Z":
            Zs.append(i)
    return Zs[-1] - As[0] + 1

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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[i] == 'Z':
        z = i + 1

print(len(s[a:z]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

S=input()

for i in range(0,len(S),1):
  if S[i]=='A':
    aind=i
    break
for i in range(len(S)-1,0,-1):
  if S[i]=='Z':
    zind=i
    break
print(zind-aind+1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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[i] == "Z":
        z = i+1

print(len(s[a:z]))

Submission status: Accepted

Solution code:
s=input()

i = 0
a = -1
b = -1
for c in s:
    i+=1
    if c == 'A':
        if a == -1:
            a = i
    elif c == 'Z':
        if b < i:
            b = i

print(b-a+1)

Submission status: Accepted

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")
# print("{}, {}".format(a, z))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
  if s[i]=="A":
    ind=i
    break
    
ex=n
for i in reversed(s):
  ex -= 1
  if i=="Z":
    break

print(ex-ind+1)

Submission status: Accepted

Solution code:
S = input()

print(S.rfind("Z")-S.find("A")+1)

Submission status: Accepted

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