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

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

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

Solution (Python):
s = list(input())

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

for j in range(len(s) - 1, 0, -1):
    if s[j] == 'Z':
        end = j
        break

print(j - i + 1)

Solution (Python):


s = input()

ans = s.rindex('Z') - s.index('A') + 1

print(ans)

Solution (Python):
s=input();l=1e9;r=0;
for i in range(len(s)):
  if s[i]=='A': l=min(l,i)
  elif s[i]=='Z'and l!=1e9:r=max(r,i)
print(r-l+1)

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

Solution (Python):
S = input()
A_index = [i for i in range(len(S)) if S[i] == "A"]
Z_index = [i for i in range(len(S)) if S[i] == "Z"]
print(len(S[A_index[0] : Z_index[-1] + 1]))

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

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

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

Solution (Python):
s=input()
p=0
q=0
r=0
m=0
for i in s:
  r +=1
  if i =='A':
    if p==0:
      p=r
  elif p!=0 and i=='Z':
    q = r
print(q-p+1)

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

Solution (Python):



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


print(z - a + 1)

Solution (Python):
s = input()

start = end = -1
ans = 0
for i, _s in enumerate(s):
    if _s == "A" and start < 0:
        start = end = i
    elif _s == "Z":
        end = i
        ans = max(ans, end - start + 1)

print(ans)

Solution (Python):
a=list(input())
ia=0
iz=0
for i in range(len(a)):
  if a[i]=="A":
    ia=i
    break
for j in range(len(a)-1,0,-1):
  if a[j]=="Z":
    iz=j
    break
print(iz-ia+1)

Solution (Python):

S = input()
flag = True
for i in range(len(S)):
    if S[i] == "A" and flag:
        start = i
        flag = False
    if S[i] == "Z":
        end = i
print(end - start + 1)

Solution (Python):
a = input()
A = a.find('A')
Z = a.rfind("Z")
print(Z-A+1)

Solution (Python):
s = list(input())

idx_a = []
idx_z = []

for idx in range(len(s)):
    if s[idx] == "A":
        idx_a.append(idx)
    elif s[idx] == "Z":
        idx_z.append(idx)

ans = idx_z[-1] - idx_a[0] + 1
print(ans)

Solution (Python):
s = input()
a = s.index("A")

rs = s[::-1]
z = rs.index("Z")

print(len(s) - a - z)

Solution (Python):
s = input()
a = s.index("A")

rs = ''.join(reversed(s))
z = rs.index("Z")

print(len(s) - a - z)

Solution (Python):
s = input()

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

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

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

Solution (Python):
S = input()

rS = S[::-1]
indexA = S.find("A")
indexrZ = rS.find("Z")
indexZ = len(S)-indexrZ

ans = indexZ - indexA

print(ans)

Solution (Python):
s = input()
A_index = s.index('A')
s = list(s)
s.reverse()
s = "".join(s)
Z_index = len(s) - s.index('Z')     
print(Z_index - A_index)

Solution (Python):
s = input().strip()
i0 = s.index("A")
for j in range(len(s)):
    if s[len(s)-1-j]=="Z":
        i1 = len(s)-1-j
        break
print(i1-i0+1)

Solution (Python):
import collections
import itertools
import functools
import math

if __name__ == "__main__":
    s = input()
    a = s.find("A")
    z = s.rfind("Z") + 1
    print(z - a)

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

Solution (Python):
s=input()

l=0
r=0
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)

Solution (Python):



import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    s = input()

    S = 0
    E = len(s)
    for i in range(len(s)):
        if s[i] == "A":
            S = i
            break
    for j in reversed(range(len(s))):
        if s[j] == "Z":
            E = j+1
            break
    print(len(s[S:E]))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """QWERTYASDFZXCV"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ZABCZ"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """HASFJGHOGAKZZFEGA"""
        output = """12"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
s=input()
a=s.index("A")
z=s.index("Z")
if __name__ == "__main__":
    index_num = [n for n, v in enumerate(s) if v == "A"]
    
if __name__ == "__main__":
    index_n = [n for n, v in enumerate(s) if v == "Z"]
    
print(max(index_n)-min(index_num)+1)

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

Solution (Python):
s = input()

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


print(z - a + 1)

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

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

Solution (Python):
"""
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'))+1)

Solution (Python):
"""
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)

Solution (Python):

s = open(0).read()

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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)



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

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

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

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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)

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

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

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

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

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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()

Solution (Python):
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)

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


for i in range(len(s)):
  if s[i]=='A':
    S=s.index(s[i])
    break
    
ss=s[::-1]


for j in range(len(ss)):
  if ss[j]=='Z':
    G=len(ss)-j-1
    break
print(G-S+1)

Solution (Python):
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]))

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

Solution (Python):
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)

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

Solution (Python):
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()

Solution (Python):
s = input()

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

Solution (Python):
s=input()

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

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

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

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

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

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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()

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
s = input()

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

Solution (Python):
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]))

Solution (Python):
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]))

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

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

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

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
s = input()

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

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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]))

Solution (Python):
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))

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

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

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

Solution (Python):
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(Z[-1]-A[0]+1)

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


if __name__ == "__main__":
    resolve()

Solution (Python):
import sys

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




S=input()

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

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
s=input()

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

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

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

Solution (Python):
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]))

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

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

Solution (Python):
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)

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

Solution (Python):
s = input()
cnt = 0

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

print(cnt)

Solution (Python):
S = list(input())

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

print (z - a + 1)

Solution (Python):
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:]))

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
s = input()



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




print(ind_Z - ind_A + 1)

Solution (Python):
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)

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

Solution (Python):
s = input()

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

print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
s = input()


n1 = s.index('A')




n2 = s.rindex('Z')




print(n2 - n1 + 1)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
s = input()

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

Solution (Python):
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)

Solution (Python):
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'):]))

Solution (Python):
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)

Solution (Python):
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'):]))

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

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

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

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

Solution (Python):
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)

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

Solution (Python):
s = input()

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

Solution (Python):
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)

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

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

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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)

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

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

Solution (Python):
s = input()

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

print(Z - A + 1)

Solution (Python):
s = input()

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


print(CZ-CA+1)

Solution (Python):
s=input()

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

d=s[mojiA:mojiZ+1]

print(len(d))

Solution (Python):
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)

Solution (Python):
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)

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

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

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

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

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)