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()
print(s.rfind("Z") - s.find("A") + 1)

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

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

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

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

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

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):
a = z = 0
f = True
for i, s in enumerate(input()):
  if f and s == 'A': 
    a = i
    f = not f
  elif s == 'Z':
    z = i
print(z - a + 1)

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

Solution (Python):
import re

s = input()

print(max([len(text) for text in re.findall("A.*Z", s)]+[0]))

Solution (Python):
s = input()
a_idx, z_idx = 200000, 0

for i in range(len(s)):
    if s[i] == 'A':
        a_idx = min(i, a_idx)
    if s[i] == 'Z':
        z_idx = i
print(z_idx - a_idx + 1)

Solution (Python):

s = input()

i = 0

while s[i] != 'A':
    i += 1

j = len(s) - 1

while s[j] != 'Z':
    j -= 1

ans = j - i + 1
print(ans)

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

l=len(S)

for i in range(l):
    if S[i]=="A":
        a=i
        break

for i in range(l-1,-1,-1):
    if S[i]=="Z":
        b=i
        break

print(b-a+1)

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

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

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

Solution (Python):
s = input()

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

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

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

Solution (Python):
s = input()

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

Solution (Python):
def main():
    S = input()
    S_start = S.find("A")
    S_fin = S.rfind("Z")
    if S_start != -1 and S_fin != -1:
        print(S_fin - S_start + 1)

if __name__ == '__main__':
    main()

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

Solution (Python):
S = list(input())
n = len(S)
s = S.index("A")
SS = S[::-1]
e = SS.index("Z")
print(n - s - e)

Solution (Python):

def main():
    s = input()


    flag = 0
    t = ""
    u = ""

    for i in s:
        if i == "A":
            flag = 1
        if flag == 1:
            t += i

    flag = 0

    for i in t[::-1]:
        if i == "Z":
            flag = 1
        if flag ==1:
            u += i

    print(len(u))

if __name__ == "__main__":
        main()

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()
flag = 0
index_A = 0
index_Z = 0
for i in range(len(s)):
    if s[i]=='A' and flag == 0:
        index_A = i
        flag = 1
    if s[i]=='Z':
        index_Z = i
ans = index_Z - index_A + 1
print(ans)

Solution (Python):


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

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

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

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


for x in a:
    if x == "A":
        b+=x
        counterf +=1
    elif counterf >=1:
        b+=x
        
for x in b[::-1]:
    if x == "Z":
        c+=x
        counter+=1
    elif counter >=1:
        c+=x
print(len(c))

Solution (Python):


s = input()

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

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

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

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

Solution (Python):
string = input()

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

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

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

first_clock = 0
last_clock = 0
F_count = 0
L_count = 0
count = -1

for i in S:
    count += 1
    if i == "A" and first_clock == 0:
        F_count = count
        first_clock = 1
    if i == "Z":
        L_count = count

else:
    print(L_count - F_count + 1)

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

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

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

Solution (Python):
s=raw_input()
L=len(s)
prefix=suffix=0
for i in xrange(L):
  if s[i]=='A': break
  prefix += 1
for i in xrange(L):
  if s[L-1-i]=='Z': break
  suffix += 1
print L-prefix-suffix

Solution (Python):
s = input()

for i, s_i in enumerate(s):
    if s_i == 'A':
        start = i
        break

for i, s_i in enumerate(s[::-1]):
    if s_i == 'Z':
        end = len(s) - i
        break

print(end - start)

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

Solution (Python):
s = input()

num_A = 0
num_Z = 0

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

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

print(num_Z - num_A + 1)

Solution (Python):
import re
print(len(re.search('A\w*Z',input()).group(0)))

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

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

Solution (Python):
s = str(input())
slist = list(s)
slr = slist[::-1]
slen = len(s)
ans1 = 0
ans2 = 0
for i in range(0,slen+1):
    if slist[i] == 'A':
        ans1 = i
        break
    else:
        pass
for j in range(0,slen+1):
    if slr[j] == 'Z':
        ans2 = slen - j
        break
    else:
        pass
print(ans2 - ans1)

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

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

Solution (Python):
s=input()
Aindex = s.find("A")
Zindex = -1
for index,character in enumerate(s[Aindex:]):
    if character == "Z":
        Zindex = index + Aindex
print(len(s[Aindex:Zindex+1]))

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

Solution (Python):
s = input()

length = len(s)

for i in range(length):
    if s[i] == "A":
        begin = i
        break

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

print(end-begin+1)

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

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

Solution (Python):
retsu=input()
nagasa=len(retsu)
first=0
last=0
for i in range(nagasa):
    if retsu[i:i+1]=="A":
        first=i
        k=i
        break
for j in range(k,nagasa):
    if retsu[j:j+1]=="Z":
        last=j
    
print(last-first+1)

Solution (Python):
s=0
l=0
n=0
for i in list(input().strip()):
  n+=1
  if i=="A" and s==0:
    s=n
  if i=="Z" and s>=1:
    l=n
print(l-s+1)

Solution (Python):
s = input()
i = 0
while i < len(s) and s[i] != "A":
    i += 1

j = len(s) - 1
while j > 0 and s[j] != "Z":
    j -= 1

print(j - i + 1)

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

Solution (Python):
s = input()
r = len(s) - 1
l = 0
while (s[l] != 'A'): l+=1
while (s[r] != 'Z'): r-=1
print(r-l+1)

Solution (Python):
s = input()
r = len(s) - 1
l = 0
while (s[l] != 'A'): l+=1
while (s[r] != 'Z'): r-=1
print(r-l+1)

Solution (Python):
s = input()
ans = []
for i in range(len(s)):
    if s[i] == "A":
        j = i
        break
for i in range(len(s)):
    if s[len(s)-i-1] == "Z":
        k = len(s)-i-1
        break
ans = k-j+1
print(ans)

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

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

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

Solution (Python):
s = input()

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

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

print(z_idx-a_idx+1)

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

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

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

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

Solution (Python):
s = list(input())
a_i = []
z_i = []
for i,c in enumerate(s):
    if c == 'A': a_i.append(i)
    elif c == 'Z': z_i.append(i)
print(max(z_i) - min(a_i) + 1)

Solution (Python):
s = list(input())
a_i = []
z_i = []
for i,c in enumerate(s):
    if c == 'A': a_i.append(i)
    elif c == 'Z': z_i.append(i)
print(max(z_i) - min(a_i) + 1)

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

start = 0
end = len(s) - 1

while True:
    if s[start] == "A":
        break
    start += 1
    
while True:
    if s[end] == "Z":
        break
    end -= 1
    
print(end - start + 1)

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

num_a = 0
num_z = 0
flag = 0
for i in range(len(strings)):
    if strings[i]=='A' and flag==0:
        num_a = i
        flag = 1
    if strings[i]=='Z':
        num_z = i
x = num_z-num_a+1
print(x)

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

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

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

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

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

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

s = arr_data[0][0]


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

Solution (Python):
S = input()

start,end=0,0

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

Solution (Python):
s = raw_input()
A = 0
Z = 0
for i in range(0, len(s)):
	if s[i] == 'A':
		A = i
		break
for i in range(0, len(s)):
	if s[-1-i] == 'Z':
		Z = len(s) - i - 1
		break

print Z - A + 1

Solution (Python):
a = input()
b = len(a)
aa = 0
zz = 0
for i in range(b-1,-1,-1):
    if a[i] == 'Z':
        zz = i
        break
for i in range(b):
    if a[i] == 'A':
        aa = i
        break

print(zz-aa+1)

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

Solution (Python):
string = list(input())
len_string = len(string)
for i in range(len_string):
    if string[i] == 'A':
        break
for j in range(len_string)[::-1]:
    if string[j] == 'Z':
        break
print(j-i+1)

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

Solution (Python):





if __name__ == '__main__':
    s = list(input())
    a_position = s.index('A')
    z_position = len(s) - s[::-1].index('Z') - 1

    print(z_position - a_position + 1)

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

Solution (Python):
s = list(input())
for x in range(len(s)-1, 0, -1):
    if s[x] == "Z":
        hold_z = x+1
        break
for x in range(len(s)):
    if s[x] == "A":
        hold_a = x+1
        break
print(hold_z - hold_a + 1)

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

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

Solution (Python):
s = input()
start_index = -1
end_index = -1
for i in range(len(s)):
    if s[i] == 'A' and start_index == -1:
        start_index = i
    elif s[i] == 'Z':
        end_index = i
print(end_index - start_index + 1)

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

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

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

start = -1
end = -1

for i, s in enumerate(S):
    if s == 'A':
        start = i
        break

for i, s in enumerate(reversed(S)):
    if s == 'Z':
        end = len(S) - i
        break

print(end - start)

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

Solution (Python):
S=input()
N=len(S)
x=0
y=N-1
p=True
q=True
for i in range(N):
  if S[i]=="A" and p:
    x=i
    p=False
  if S[N-i-1]=="Z" and q:
    y=N-i-1
    q=False
print(y-x+1)

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

Solution (Python):
S=input()
st=len(S)
en=0
for i in range(len(S)):
  if S[i]=='A':
    st=min(st,i)
  if S[i]=='Z':
    en=max(en,i)
print(en-st+1)

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

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

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

Solution (Python):
import sys
s=input()
begin=0
end=0
for i in range(len(s)):
    if(s[i]=="A"):
        begin=i
        break

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

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

Solution (Python):
S=list(input())
A=[]
Z=[]
for i in range(len(S)):
    if S[i]=="A":
        A.append(i)
    elif S[i]=="Z":
        Z.append(i)

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

Solution (Python):
a = list(input())
cou = len(a)
b = 0
c = -1
while a[b] != "A":
    cou -= 1
    b += 1
while a[c] != "Z":
    cou -= 1
    c -= 1
print(cou)

Solution (Python):
s = input()
isAdd = False
l = -1
r = -1
for i in range(len(s)):
    if s[i] == 'A' and l == -1: l = i
    if s[len(s)-1-i] == 'Z' and r == -1: r = len(s)-1-i

print(r-l+1)

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

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

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

Solution (Python):
S = input()
a = S.find('A')
z = S[::-1].find("Z")
print(len(S[a:-(1+z)])+1)

Solution (Python):
import re
s = input()
ma = re.search(r"A.+Z", s)
print(len(ma.group()))

Solution (Python):
S = input()
a = S.find('A')
z = S[::-1].find("Z")
print(len(S[a:-(1+z)])+1)

Solution (Python):

s = input()

while True:
    if s[0] != 'A':
        s = s[1:]
        continue
    if s[-1] != 'Z':
        s = s[:-1]
        continue
    break

print(len(s))

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

Solution (Python):
def main():
    """
    |s| <= 2 * 10 ** 5
    """
    s = input()

    for i, c in enumerate(s):
        if c == "A":
            start = i
            break

    for i, c in enumerate(s[start + 1:], start + 1):
        if c == "Z":
            end = i

    ans = end - start + 1
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
print(len(input().lstrip("BCDEFGHIJKLMNOPQRSTUVWXYZ").rstrip("ABCDEFGHIJKLMNOPQRSTUVWXY")))

Solution (Python):
s1 = input()
s2 = s1[::-1]
for i in range(len(s1)):
	if s1[i] == "A":
		start = i + 1
		break
for i in range(len(s2)):
	if s2[i] == "Z":
		goal = len(s2) - i 
		break

print(goal - start + 1)

Solution (Python):
val =input()
res = val.find("A")
res2 = len(val) - val[::-1].find("Z")
print(res2-res)

Solution (Python):
def main():
    S = list(input())
    A = []
    Z = []
    for x in range(len(S)):
        if S[x] == "A":
            A.append(x)
        elif S[x] == "Z":
            Z.append(x)

    print(max(Z) - min(A) + 1)


if __name__ == "__main__":
    main()

Solution (Python):
def solve():
    s = list(input())
    posi_A = s.index("A")
    s.reverse()
    posi_Z = s.index("Z")

    print( (len(s) - posi_Z) - posi_A)


solve()

Solution (Python):
s = input()
a_pos = s.index("A")
z_pos = s.rindex('Z')

print(z_pos + 1 - a_pos)

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

Solution (Python):
import re
S = input()
print(max(len(it.group()) for it in re.finditer("A[A-Z]*Z", S)))

Solution (Python):
s = input()

start = s.find("A")
end = s.rfind("Z")

print(end - start + 1)

Solution (Python):
a = float('inf')
z = -1
 
s = input()
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()

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

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

print(len(s)-cnt_Z-cnt_A)

Solution (Python):
a = 10**9
z = 0

s = input()
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()
print(s.rfind('Z') - s.find('A') + 1)

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

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

Solution (Python):
def main():
    s = input()
    max_len = -1
    idx_a, idx_z = [], []
    for i in range(len(s)):
        if s[i] == 'A':
            idx_a.append(i)
        if s[i] == 'Z':
            idx_z.append(i)
    print(max(idx_z)-min(idx_a)+1)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
def solution():
	a = raw_input()
		
	aIdx = 0
	zIdx = 0
	maxLength = 0
	hasSet = False
	for i in range(len(a)):
		if a[i] == 'A' and not hasSet:
			aIdx = i
			hasSet = True
		
		if a[i] == 'Z':
			zIdx = i 

	print zIdx - aIdx + 1

solution()

Solution (Python):
s = input()

indexA = 0
indexZ = len(s)

for i in range(indexZ):
	if s[i] == "A":
		indexA = i
		break

s = s[::-1]

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

print(indexZ - indexA)

Solution (Python):
import re
s = input()
a = re.search(r"A.+Z", s)
print(len(a.group()))

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

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

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

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

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

Solution (Python):
s = input()

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

Solution (Python):
import sys
inp = sys.stdin.read().strip()
ctr, maks = -1, 0
for idx in range(len(inp)):
	if inp[idx] == 'A' and ctr == -1:
		ctr = 1
	else:
		if ctr != -1: ctr += 1
		if inp[idx] == 'Z':
			maks = max(ctr, maks)
print maks

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

a=s.index("A")

s.reverse()

b=s.index("Z")

s.reverse()

if b==0:
    T=s[a:-1]
    print(len(T)+1)
else:
    T=s[a:-b]
    print(len(T))

Solution (Python):





def main():
    s = input()

    idx_min = s.index("A")
    idx_max = s.rindex("Z")
    print(idx_max - idx_min + 1)

if __name__ == "__main__": main()

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

index1 = s.index("A")
temp = s[::-1].index("Z")
index2 = len(s) - temp

print(index2 - index1)

Solution (Python):
s = input()
a, z, ans = (0, 0, 0)
 
a = s.find("A")
z = s.rfind("Z")
ans = z - a + 1
print(ans)

Solution (Python):
s = list(raw_input())
flag1 = True
flag2 = True
for i in range(len(s)):
	if s[i] == 'A' and flag1:
		startIndex = i
		flag1 = False
	if s[len(s) - i - 1] == 'Z' and flag2:
		endIndex = len(s) - i
		flag2 = False
	if not flag1 and not flag2:
		break

print endIndex - startIndex

Solution (Python):
s=input().strip()
rev=s[::-1]
n=len(s)

print((n-rev.find('Z')) - (s.find('A')))

Solution (Python):
S = input()

s_ind = 0
e_ind = 0


for i, s in enumerate(S):
    if s == "A":
        s_ind = i
        break
        
for i in range(len(S)):
    if S[-(i+1)] == "Z":
        e_ind = len(S)-(i+1)
        break
        
print(e_ind - s_ind + 1)

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

Solution (Python):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

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

Solution (Python):
from collections import defaultdict


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


if __name__ == '__main__':
    main()

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

Solution (Python):
s = input()
l = len(s)
sp = 0
gp = l - 1

while sp < l:
  if s[sp] == 'A':
    break
  sp += 1
  
while gp >= -1:
  if s[gp] == 'Z':
    break
  gp -= 1

if gp > sp:
  print(gp - sp + 1)
else:
  print(0)

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

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

Solution (Python):
s = input()

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

s2 = s[-1:0:-1]
for j in range(len(s2)):
    if s2[j] == "Z":
        z = len(s)-1-j
        break

print(z-a+1)

Solution (Python):
print(len(max(__import__("re").findall('A.*Z', input()))))

Solution (Python):
s = raw_input()
start = s.index('A')
end = s.rindex('Z')
print end - start + 1

Solution (Python):
S = input()
i = 0
j = -1

while True:
    if S[i] == "A":
        A = i
        break
    i += 1

while True:
    if S[j] == "Z":
        Z = len(S) + j
        break
    j -= 1
    
print(Z - A + 1)

Solution (Python):
s = input()

start = s.find('A')
end = s.rfind('Z')

print(end+1-start)

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

Solution (Python):
import re; print len(re.compile("A.*Z").search(raw_input()).group(0))

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

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

Solution (Python):
s = raw_input()
left = min([i for i in range(len(s)) if s[i] == 'A'])
right = max([i for i in range(len(s)) if s[i] == 'Z'])
print (right - left + 1)

Solution (Python):


s = raw_input()
print(s.rfind('Z')-s.find('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(len(S))[::-1]:
    if(S[i] == "Z"):
      b = i
      break

print(b - a + 1)

Solution (Python):
s = input()

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

b = 0
for i in reversed(range(0, len(s))):
    if s[i] == 'Z':
        b = i
        break

print((b - a) + 1)

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

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

Solution (Python):

s = raw_input()
start = s.index("A")
end = s.rindex("Z")
print end - start + 1

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

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

print(max(result))

Solution (Python):
if __name__ == "__main__":
    s = input()
    i1 = s.find('A')
    i2 = s.rfind('Z')
    print(i2-i1+1)

Solution (Python):
x = list(input())
a = []
z = []

for i in range(len(x)):
    if x[i] == 'A':
        a.append(i)
    elif x[i] == 'Z':
        z.append(i)
    else:
        pass

print(max(z) - min(a) + 1)

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

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

Solution (Python):
s=raw_input()
l=len(s)
a=None
b=None
a=s.find('A')
s=s[::-1]
b=s.find('Z')
print l-b-a

Solution (Python):
def main():
  s = input()
  si , ei = 0, len(s) - 1
  while True:
    if s[si] == 'A':
      break
    si += 1
  while True:
    if s[ei] == 'Z':
      break
    ei -= 1
  print(ei - si + 1)

if __name__ == '__main__':
  main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    s = S()
    a = s.index('A')
    z = s.rindex('Z')
    return z-a+1

print(main())

Solution (Python):
s = input()


def main(s):
    a_index = 200000 
    z_index = -1
    i = 0

    for c in s:
        if c == 'A':
            a_index = min(a_index, i)
        elif c == 'Z':
            z_index = max(z_index, i)
        i += 1

    return (z_index - a_index) + 1


print(main(s))

Solution (Python):
def main():
    s = input()
    si, ei = 0, len(s) - 1
    while True:
        if s[si] == 'A':
            break
        si += 1
    while True:
        if s[ei] == 'Z':
            break
        ei -= 1
    print(ei - si + 1)

if __name__ == '__main__':
    main()

Solution (Python):

if __name__ == '__main__':
  s = str(input())
  L = len(s)
  beg = -1
  end = -1
  for i in range(0,L):
    if s[i]=='A' and beg==-1:
      beg = i
    elif s[i]=='Z':
      end = i
  print(end-beg+1)

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

Solution (Python):
import sys

def solve():
    s = input()
    l = s.find('A')
    r = s.rfind('Z')

    print(r - l + 1)
    
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

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

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

Solution (Python):


words=input().rstrip()

a=words.find("A")
z=words.rfind("Z")

print(z-a+1)

Solution (Python):
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

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

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

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

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

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

Solution (Python):








def sol(strs):

	ptrA=0;
	ptrZ=len(strs)

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

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

	return (ptrZ - ptrA+1)





inD =raw_input()

inD = str(inD)

print sol(inD)

Solution (Python):


s = input()

x = s.find('A')
y = 0
for i in range(len(s)):
    if s[i] == 'Z':
        y = i + 1

print(y-x)

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

f = False
c = 0
max_c = 0

for k, i in enumerate(S):
    if i == 'A' and f == False:
        f = True
        c += 1
    elif i == 'Z' and f == True:
        c += 1
        max_c = max(c, max_c)
        if S[k] != 'Z':
            f = False
    elif f == True:
        c += 1

print(max_c)