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):
import re

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

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

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

print(len(s)-a-z)

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

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

Solution (Python):
s=input()

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

Solution (Python):
s = str(input())
start = len(s)
stop = 0
for i in range(len(s)):
  if s[i] == 'A':
    start =  min(i,start)
  elif s[i] == 'Z':
    stop = max(i, stop)
  else:
    pass
print(stop-start+1)

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

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

Solution (Python):



s = input()
s_len = len(s)


a_pos = 0
z_pos = 0


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


for i in range(s_len):
    z = s[i]
    if z=='Z':
        z_pos = i

print(z_pos - a_pos + 1)

Solution (Python):
import re
s = input()
found = re.findall("A.*Z", s)
strings = found[0]
count = 0
for i in strings:
    count += 1
print(count)

Solution (Python):
s = input()
a = []
z = []
for i in range(len(s)):
    if s[i] == "A":
        a.append(i)
    elif s[i] == "Z":
        z.append(i)
ans = max(z) - min(a) + 1
print(ans)

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

Solution (Python):
s = input()
A, Z = [], []
for i in range(len(s)):
    if s[i]=="A":
        A.append(i)
    elif s[i]=="Z":
        Z.append(i)
A, Z = min(A), max(Z)
print(len(s[A:Z+1]))

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

Solution (Python):
s=input()
li=[str(i) for i in s]
startA=li.index("A")+1

li.reverse()
endZ=len(li)-li.index("Z")+1

print(endZ-startA)

Solution (Python):

s=list(input())
flag=0
for i in range(len(s)):
    if s[i]=="A":start=i;break
for j in range(len(s)-1,0,-1):
    if s[j]=="Z":finish=j;break
s2=len(s[start:finish+1])
print(s2)

Solution (Python):
s = input()
n = s.index("A")
s_reverse_list = list(reversed(s))
s_reverse = "".join(s_reverse_list)
m = s[n:len(s) - s_reverse.index("Z")]
print(len(m))

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

Solution (Python):











mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

if __name__=='__main__':
    main()

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

Solution (Python):
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    n=0
    a=100000000
    z=0
    for s in ss:
        if s=="A":
            a=min(a,n)
        elif s=="Z":
            z=n
        n+=1
    print(z-a+1)
    return


resolve()

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

a_ind = s.index("A")
z_ind = s_r.index("Z")
z_ind = len(s) - z_ind

ans = z_ind - a_ind

print(ans)

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

a_ind = [i for i, v  in enumerate(s) if v == "A"]
z_ind = [i for i, v in enumerate(s) if v == "Z"]


ans = z_ind[-1] - a_ind[0] + 1

print(ans)

Solution (Python):


import copy


def solver(givenstring):
    result = 0
    usestrA = copy.copy(givenstring)
    usestrZ = copy.copy(givenstring)

    apos = usestrA.index('A')+1
    usestrrevZ = usestrZ[::-1]
    zpos = len(givenstring) - usestrrevZ.index('Z')
    result = zpos - apos + 1
    return result


if __name__ == "__main__":
    s = input()
    print("{}".format(solver(s)))

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

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

Solution (Python):
s = input()
ans, val = 0, -200001
for c in s:
    if c == 'A' and val < 0:
        val = 1
    elif c == 'Z':
        val += 1
        ans = max(ans, val)
    else:
        val += 1
print(ans)

Solution (Python):




def solver(string):
    result = 200000
    aposi = 0
    zposi = len(string)
    for j in range(0, len(string), 1):
        if string[j] == 'A':
            aposi = j
            break
    for j in range(len(string)-1, -1, -1):
        if string[j] == 'Z':
            zposi = j
            break
    result = zposi - aposi + 1
    return result


if __name__ == "__main__":
    s = input()
    print('{}'.format(solver(s)))

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

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

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

Solution (Python):
s=input()
words=[a for a in s]
kazu=len(words)
count=1
for a in words:
    if not a=='A':
        count+=1
    else:
        break
usiro=1
for b in reversed(words):
    if not b=='Z':
        usiro+=1
    else:
        break
print(kazu+2-count-usiro)

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

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

Solution (Python):
s = list(input())
a_ind = []
z_ind = []
for i, v in enumerate(s):
    if v == "A":
        a_ind.append(i)

    if v == "Z":
        z_ind.append(i)

print((max(z_ind) - min(a_ind)) + 1 )

Solution (Python):
import sys

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

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

main()

Solution (Python):
import re
s = input()
print(len(re.findall("A(.+)Z", s)[0]) + 2)

Solution (Python):
s=input()
ia=None
iz=None
for i,c in enumerate(s):
  if ia==None and c=="A":
    ia=i
  if c=="Z":
    iz=i
print(iz-ia+1)

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

Solution (Python):
S = input()

start = 0
end = 0

for i, s in enumerate(S):
  if s == 'A' and start == 0:
    start = i + 1
  if s == 'Z' and start > 0 :
    end = i+1
      
print(end - start + 1)

Solution (Python):
s = input().rstrip('\r')
start = -1
end = -1
for i, c in enumerate(s):
    if c == 'A' and start == -1:
        start = i
    if c == 'Z':
        end = i
print(end-start+1)

Solution (Python):
s = list(str(input()))
f = 0
ans = ""
first = s.index("A")
last = s.index("Z")
for i in range(len(s)):
    if s[i] == "Z":
        last = i
print(last - first + 1)

Solution (Python):


import copy


class Problem:
    def __init__(self, stringdata):
        self.stringdata = stringdata

    def solver(self):
        strcont = copy.copy(self.stringdata)
        result = 0
        rightposition = 0
        leftposition = len(strcont)
        j = 0
        while True:
            if strcont[j] == 'A':
                rightposition = j
                break
            else:
                j = j + 1
        j = leftposition - 1
        while True:
            if strcont[j] == 'Z':
                leftposition = j
                break
            else:
                j = j - 1

        result = leftposition - rightposition + 1
        return result


if __name__ == "__main__":
    s = input()
    print("{}".format(Problem(s).solver()))

Solution (Python):
l = list(input())
m = list(reversed(l))
x,y = [],[]
x = l.index('A')
y = m.index('Z')
print(len(l)-y - x)

Solution (Python):
s=list(input())
flag=True
for i in range(len(s)):
    if flag==True and s[i]=="A":
        start=i
        flag=False
    if s[i]=='Z':
        goal=i
print(goal-start+1)

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

Solution (Python):
s = input()

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

print(len(s)-i-j)

Solution (Python):

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

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

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

Solution (Python):

import sys


def solve(s: str):
    print(s.rindex("Z") - s.index("A") + 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  
    solve(s)


if __name__ == '__main__':
    main()

Solution (Python):


s=input().strip()

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

for i,word in enumerate( reversed(s) ):
    if word == "Z":
        end = len(s)-1-i
        break

print( end-start+1 )

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

Solution (Python):
s = input()
a = -1

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

print(z - a + 1)

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

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

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

print(zg-sa+1)

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

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

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

Solution (Python):
def main():
    string = input()
    begin_index = -1
    end_index = 0
    for i in range(len(string)):
        if string[i] == "A" and begin_index < 0:
            begin_index = i
        elif string[i] == "Z":
            end_index = i
    print(end_index - begin_index + 1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = readline().rstrip().decode('utf-8')
n = len(s)
for i in range(n):
    if s[i] == "A":
        start = i
        break

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

print(end-start+1)

Solution (Python):
s = str(input())
Acount = 3000000
Zcount = 0
for i in range (len(s)):
    if (s[i] == 'A' and i < Acount):
        Acount = i

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

print(Zcount - Acount +1)

Solution (Python):
s = input()
i = 0
while s[i]!="A":
    i += 1
j = -1
while s[j]!="Z":
    j -= 1
print(len(s)-i+j+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")

b = max([i for i,x in enumerate(s) if x == "Z"])

print(b-a+1)

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

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

Solution (Python):

s=input()
Flg=True
for i in range(len(s)):
    if Flg:
        if s[i]=='A':
            ia=i
            Flg=False
    if s[i]=='Z':
        iz=i
print(iz-ia+1)

Solution (Python):
s = input()

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

Solution (Python):
s=input()

while s[0]!="A":
    s=s[1:]

while s[-1]!="Z":
    s=s[:-1]

print(len(s))

Solution (Python):
s = input()
left = 0
right = len(s) - 1
while True:
    if s[left] == "A":
        break
    else:
        left += 1
while True:
    if s[right] == "Z":
        break
    else:
        right -= 1
print(right - left + 1)

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

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

Solution (Python):
S = input()
a, z = 0, 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(z-a+1)

Solution (Python):
s = input()

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

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

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

Solution (Python):
s = input()

A = s.find('A')

i = 0

for s_i in reversed(s):
    if s_i == 'Z':
        break
    i += 1

Z = len(s) - i - 1

print(Z-A+1)

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

begin = s.index("A")
end = list(reversed(s)).index("Z")
print(len(s[begin:len(s)-end]))

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

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

Solution (Python):
S=input()
while S[0]!="A":
    S=S.lstrip(S[0])
while S[-1]!="Z":
    S=S.rstrip(S[-1])
print(len(S))

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

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

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

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

Solution (Python):



s = input().strip()

loc_A=len(s)+1
loc_Z=-1
for i in range(len(s)):
    if s[i] == "Z" and loc_Z < i:
        loc_Z = i
    elif s[i] == "A" and i < loc_A:
        loc_A = i

print( loc_Z - (loc_A - 1) )

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

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

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

a = s.index('A')
z = rs.index('Z')

print(len(s)-z - a )

Solution (Python):
s = input()

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

Solution (Python):
A = input()
N = len(A)
for i in range(N):
    if A[i] == "A":
        posA = A.index(A[i])
        break
p = 0
for j in range(0, N):
    if A[j] == "Z" and j > p:
        p = j
p += 1
print(len(A[posA:p]))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    s = input()
    min_a_index = min([i for i, c in enumerate(s) if c == "A"])
    max_z_index = max([i for i, c in enumerate(s) if c == "Z"])
    print(max_z_index - min_a_index + 1)

if __name__ == '__main__':
    main()

Solution (Python):
s = input()

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

Solution (Python):
s = input()

Min_a = len(s)
Max_z = 0

for i in range(len(s)):
  if s[i] == "A":
    if i < Min_a:
      Min_a = i
  elif s[i] == "Z":
    if Max_z < i:
      Max_z = i
  
ans = Max_z - Min_a + 1

print(ans)

Solution (Python):


s = str(input())

a = s.find('A')
z = s.rfind('Z')

print(z-a+1)

Solution (Python):
s = input()

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

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

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

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

Solution (Python):
s=input()

def idx_z(s, key):
    for i in range(len(s)-1,0,-1):
        if s[i]==key: return i

pos_Z = idx_z(s,'Z')
pos_A = s.index('A')
print(int(pos_Z)-int(pos_A)+1)

Solution (Python):
s = input()
print(max([i for i, x in enumerate(s) if x == 'Z'])-min([i for i, x in enumerate(s) if x == 'A'])+1)

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

Solution (Python):
S = input()

A = int(S.find("A"))
Z = int(S.rfind("Z"))

print(Z-A+1)

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

Solution (Python):
s=input()

ans=0
a=10**6
z=-1
for i in range(len(s)):
    if s[i]=="A":
        a=min(a,i+1)
    if s[i]=="Z":
        z=max(z,i+1)
ans=z-a+1
print(ans)

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

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

Solution (Python):
s = input()
a = s.index("A")
zList = [i for i , name in enumerate(s) if name == "Z"]
z = zList[-1]
print(z - a + 1)

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

Solution (Python):
s = input()

max = -1
buf = []
flag = False

for i in range(len(s)):
    if flag == True:
        buf.append(s[i])
        if s[i] == 'Z':
            if len(buf) >= max:
                max = len(buf)
    elif s[i] == 'A':
        buf.append(s[i])
        flag = True

print(max)

Solution (Python):
s = input()
begin = 0
last = len(s)-1
for i in range(len(s)):
  if s[i] == 'A':
    begin = i
    break
for i in range(len(s)-1, -1, -1):
  if s[i] == 'Z':
    last = i
    break
print(last-begin+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':
        z = i
        break
print(z-a+1)

Solution (Python):
a=input()
a= a.split("A",1)[1]
a=a.rsplit("Z",1)[0]
print(len(a)+2)

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

Solution (Python):
N=input()

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

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

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

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

Solution (Python):
s = input()
counter_A = 0
counter_Z = 0
for i in s:
    if i == 'A':
        break
    else:
        counter_A += 1
for i in s[::-1]:
    if i == 'Z':
        break
    else:
        counter_Z += 1
print(len(s) - counter_A - counter_Z)

Solution (Python):
s = input()
first_A = 200000
last_Z = 0

for index, word in enumerate(s):
    if word == "A":
        if first_A >= index:
            first_A = index
    if word == "Z":
        if last_Z <= index:
            last_Z = index

ans = last_Z - first_A + 1
print(ans)

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

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

Solution (Python):


s=input()
a=-1
z=-1

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

Solution (Python):




def main():
    S = list(input())
    print(len(S) - S[::-1].index('Z') - S[::1].index('A'))


if __name__ == "__main__":
    main()

Solution (Python):
s=input()
N=len(s)
f=s.index("A")
F=0
for i in range(N):
    if s[i]=="Z":
        F=i
print(F-f+1)

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

Solution (Python):
str = input()
count = 0
isCount = False
answer = 0
for id in range(len(str)):
    if isCount == False and str[id] == "A": 
        count = 0
        isCount = True
    if isCount == False: continue
    count += 1
    if str[id] == "Z": 
        answer = max(answer, count)
print(answer)

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

Solution (Python):
s_raw = list(map(str, input()))
ans = []

for i in range(0, len(s_raw)):
	if s_raw[i] == 'A':
		for k in range(i, len(s_raw)):
			ans.append(s_raw[k])
		break

for i in range(0, len(ans)):
	if ans[i] == 'Z':
		index = i
		
print(index + 1)

Solution (Python):

s = list(str(input()))

numberA = []
numberZ = []
for i in range(len(s)):
    if s[i] == 'A':
        numberA.append(i)
    if s[i] == 'Z':
        numberZ.append(i)
print(max(numberZ) - min(numberA) + 1)

Solution (Python):
s = input()

start = []
end = []
for i in range(len(s)):
    if s[i] == "A":
        start.append(i)
    if s[-(i+1)] =="Z":
        end.append(len(s)-i)
print(end[0]-start[0])

Solution (Python):
a = input()
import re
start = re.search(r"^[^A]*A", a).end()
goal = re.search(r"Z[^Z]*$", a).start()
print(goal - start + 2)

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

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

Solution (Python):
s = input()
import collections
from collections import deque
list_A = deque()
list_Z = deque()
for i in range(len(s)) :
    if s[i] == "A" :
        list_A.append(i)
    if s[i] == "Z" :
        list_Z.append(i)
print(list_Z[-1] - list_A[0] + 1)

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

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

Solution (Python):
w=input()
for i in range(len(w)):
    a=w.find('A')
    b=w.rfind('Z')
print(b-a+1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = input()

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

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

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


def main():
    S = INPUT()

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

    print(z - a + 1)


if __name__ == '__main__':
    main()

Solution (Python):

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

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

Solution (Python):
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().decode('utf8')
print(-S.find('A') + S.rfind('Z') + 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[len(s)-1-i] == 'Z':
        b = len(s)-i-1
        break

print(b-a+1)

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

a = s.find('A')
z = s.rfind('Z')

print(z-a+1)

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

print(ans)

Solution (Python):
s=str(input())
can=0
ans=int(0)
for i in range(len(s)):
    if s[i]=='A':
        can=1
    
    if can:
        ans+=1

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

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

Solution (Python):
s = input()

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

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

if end > start:
    print(end - start)
else:
    print(0)

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

Solution (Python):
s = input()
a = 0
z = 0
num = len(s)

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

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()
s_rev = s[::-1]
len = len(s)
for i in s:
    if i == "A":
        break
    else:
        len -= 1
for k in s_rev:
    if k == "Z":
        break
    else:
        len -= 1
print(len)

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

Solution (Python):
def solve():
    S = input()

    

    head = S.index("A")
    tail = S[::-1].index("Z")
    tail = len(S) - tail

    return S[head:tail]


if __name__ == '__main__':
    res = solve()
    print(len(res))

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

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

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

Solution (Python):
import re
s = input()
pattern = 'A.*Z'
print(len(re.search(pattern, s, flags=0).group()))

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

print(len-a-z)

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

Solution (Python):

def main():
    s = input()
    A_index = s.index('A')
    t = [i for i in reversed(s)]
    Z_index = len(s) - t.index('Z') - 1

    if Z_index - A_index >= 0:
        print(Z_index - A_index + 1) 

main()

Solution (Python):
s=input()
print(len(s.split("A",1)[1].rsplit("Z",1)[0])+2)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    S=STR()
    sl=len(S)
    for i in range(sl):
        if S[i]=='A':
            cta=i
            break
    for i in range(sl):
        if S[(sl-1)-i]=='Z':
            ctz=sl-1-i
            break
    print(ctz-cta+1)
if __name__ == '__main__':
    do()

Solution (Python):
string = input()

len = len(string)

for s in string:
    if s == "A":
        break
    else:
        len -= 1

for s in string[::-1]:
    if s == "Z":
        break
    else:
        len -= 1

print(len)

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

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

Solution (Python):
a=input()
l=[]
for i,v in enumerate(a):
    if v=="Z":
        l.append(i)
print(int(l[-1])-a.index("A")+1)

Solution (Python):
s=input()
a=s.index('A')
while len(s)>=2:
    if s[-1]=='Z':
        print(len(s[a:]))
        break
    else:
        s=s[:-1]

Solution (Python):
s = input()
f = s.index("A")
l = 0

for i, v in enumerate(s[::-1]):
	if v == "Z":
		l = len(s) - i
		break

print(l-f)

Solution (Python):
import re
s = input()
print(len(re.findall('A.*Z', s)[0]))

Solution (Python):
s=list(input())
a=0 
ans=1
z_index=0
for i in range(len(s)):
    if a==0 and s[i]=="A":
        ans-=i
        a=1
        
    if a==1 and s[i]=="Z":
        z_index=i
        
print(ans+z_index)