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()
top, last = 0, 0
for i, c in enumerate(s):
    if c == 'A':
        top = i
        break

for j, c in enumerate(s[::-1]):
    if c == 'Z':
        last = len(s) - j
        break
print(last - top)

Solution (Python):
s = input()

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

Solution (Python):
s = input()

a_index = s.index("A")
z_index = int()
for i in range(len(s)):
    if s[i] == "Z":
        z_index = i

ans = z_index - a_index + 1
print(ans)

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

    n = len(s)
    start = -1
    for i in range(n):
        if s[i] == 'A' and start == -1:
            start = i
        if s[i] == 'Z':
            end = i

    ans = end - start + 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
S = list(map(str, input().rstrip()))

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

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

print(len(S[start:len(S)-end]))

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

Solution (Python):
s = input()
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) + 1 - i
        break
print(b - a)

Solution (Python):

s = input()
i = s.find("A")
j = s.rfind("Z")

print(j-i+1)

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

Solution (Python):
s = input()

ans_a = s.index("A")
ans_z = s.rfind("Z")

print(ans_z - ans_a + 1)

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

Solution (Python):
s = input()

a = s.find("A")
z = s.rfind("Z", a)

print(z - a + 1)

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

Solution (Python):


def main():
    s = input()

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

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import sys
import math
import bisect

def main():
    s = input()
    n = len(s)
    l = 0
    r = n - 1
    while l < n and s[l] != 'A':
        l += 1
    while r >= 0 and s[r] != 'Z':
        r -= 1
    print(r - l + 1)

if __name__ == "__main__":
    main()

Solution (Python):
s = input()

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

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

Solution (Python):
S = input()
A = ''
Z = ''
for i, s in enumerate(S):
    i += 1
    if A == '':
        if s == 'A':
            A = i
    if not A == '':
        if s == 'Z':
            Z = i
print(Z - A + 1)

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

print(lz[-1] - la[0] + 1)

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

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

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

Solution (Python):
S=input()

i=0
while i<len(S):
    if S[i]=='A':
        break  
    i+=1  
j=1
while j<=len(S):
    if S[-j]=='Z':
        break
    j+=1

print(len(S)-i-j+1)

Solution (Python):
def main():
    s = input()

    a_index = []
    z_index = []

    for i, ss in enumerate(s):
        if ss == 'A':
            a_index.append(i)
        elif ss == 'Z':
            z_index.append(i)
    print(max(z_index)-min(a_index)+1)


if __name__ == "__main__":
    main()

Solution (Python):
s = str(input())
a = 200000
z = 0
for i in range(len(s)):
    if s[i] == "A":
        a = min(a, i)
    elif s[i] == "Z":
        z = max(z, i)

print(z - a + 1)

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

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

Solution (Python):
s=input()
A1=0
A2=0
for i in range(len(s)):
    if s[i]=='A':
        A1=i
        break
    else:
        continue
for t in range(len(s)-1,1,-1):
    if s[t]=='Z':
        A2=t
        break
    else:
        continue
print(A2-A1+1)

Solution (Python):
s=input()
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
ans=y-x+1
print(ans)

Solution (Python):
s = input()

a = s.index("A")
b = s[::-1].index("Z")

print(len(s) - b - a)

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

Solution (Python):
s = input()

first = s.find('A')
last = s.rfind('Z')

print(len(s[first:last+1]))

Solution (Python):
s = input()

n = len(s)

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

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

print(end+1-start)

Solution (Python):
s = input()
ls = len(s)
for i in range(ls):
  if s[i]=="A":
    firstA = i
    break
for i in range(ls):
  if s[ls-1-i]=="Z":
    lastZ = ls-i
    break
print(lastZ-firstA)

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 accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

S = input()

for i in range(len(S)):
	if S[i] == "A":
		left = i
		break

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

print(right-left+1)

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

a_index = s.index('A')
z_index = s.rfind('Z')
print(z_index-a_index+1)

Solution (Python):
s = input()

A_list = []
Z_list = []

for i, char in enumerate(s, 1):
    if char == "A":
        A_list.append(i)

for i, char in enumerate(s, 1):
    if char == "Z":
        Z_list.append(i)

print(int(max(Z_list) - min(A_list) + 1))

Solution (Python):

s = input()

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

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

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

Solution (Python):
a = -1
z = 0
for i, c in enumerate(input()):
  if c == "A" and a == -1: a = i
  if c == "Z": z = i

print(z-a+1)

Solution (Python):
S = input()

a = None
z = None
for i in range(len(S)):
    if a is None and S[i] == "A":
        a = i

    if z is None and S[~i] == "Z":
        z = len(S) - i

print(z - a)

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

Solution (Python):
s = input()
start = 0
end = 0

for x in s:
    if x == 'A':
        break
    else:
        start += 1

for x in reversed(s):
    if x == 'Z':
        break
    else:
        end += 1

print(len(s) - start - end)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

st = None
en = None
for i in range(len(s)):
    if st is None and s[i] == 'A':
        st = i
    if en is None and s[-i-1] == 'Z':
        en = -i - 1
print(len(s[st:en]) + 1)

Solution (Python):


s = input()

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

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

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

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

Solution (Python):
import re
s = input()
print(len(max(re.findall(r"A.*Z", s))))

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

Solution (Python):
import bisect
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()
print(s.rfind('Z') - s.find('A') + 1)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


s=list(input().rstrip())
for i in range(len(s)):
    if s[i]=="A":
        st=i
        break
for i in range(len(s)):
    if s[i]=="Z":
        stop=i
print(stop-st+1)

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

Solution (Python):

def main():
    s = input()
    for i,c in enumerate(s):
        if c == "A":
            a_pointer = i+1
            break

    for i,c in enumerate(s):
        if c == "Z":
            b_pointer = i+1
            continue
    print(b_pointer - a_pointer +1)


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

sl = list(s)

for i in range(0,len(sl)-1):
    if sl[i] == "A":
        st = i+1
        break
for j in range(len(sl),0,-1):
    if sl[j-1] =="Z":
        en = j
        break

print (en-st+1)

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

Solution (Python):
s = input()
st = 0
fi = 0
for i in range(len(s)):
  if s[i] == 'A':
    st = i
    break
for j in range(len(s)):
  if s[len(s)-1-j] == 'Z':
    fi = j
    break
print(len(s)-st-fi)

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

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

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

Ans1=0
for index in range(len(s)):
    if s[index]=="A":
        Ans1=index
        break

Ans2=0
for index in reversed(range(0,len(s))):
    if s[index]=="Z":
        Ans2=index
        break
        
print(Ans2-Ans1+1)

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

Solution (Python):


def main():
    s = input()

    loc_A = min([i for i, x in enumerate(s) if x == 'A'])
    loc_Z = max([i for i, x in enumerate(s) if x == 'Z'])
    print(loc_Z - loc_A + 1)


main()

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   
    
    cnt = s.rfind('Z')-s.find('A')+1
    
    print(cnt)

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

Solution (Python):
S = input()

a = S.index("A")
b = [i for i, x in enumerate(S) if x == 'Z']
c = 0
for i in range(len(b)):
    if c <= b[i]:
        c  = b[i]
print(c-a+1)

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

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

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

Solution (Python):
def resolve():
    
    n = input()
    
    
    
    
    
    
    
    

    s = n.index("A")

    emax=0
    for i in range(len(n)):
        if n[i] == "Z":
            emax = i

    print(emax - s +1)


resolve()

Solution (Python):

s = str(input())
L = len(s)

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

for j in reversed(range(L)):
    if s[j] == "Z":
        break

print(j-i+1)

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

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

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

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

Solution (Python):
S=input()

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

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

Solution (Python):
I = lambda: map(int, input().rstrip().split())
s = input()
flag = 1
for i in range(len(s)):
    if s[i] == "A" and flag == 1:
        start = i
        flag = 0
    elif s[i] == "Z":
        end = i
print(end - start + 1)

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

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

Solution (Python):
import sys

input = sys.stdin.readline
MOD = 1000000007

s = input()[:-1]

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

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    s = IS()
    n = len(s)
    l = r = 0
    for i,si in enumerate(s):
        if si == 'A':
            l = i
            break
    for i,si in enumerate(s[::-1]):
        if si == 'Z':
            r = n-i
            break
    print(r-l)

if __name__ == '__main__':
    main()

Solution (Python):


s=input()

flag=False
cnt=1
ans=0
for i in range(len(s)):
    if flag:
        cnt+=1
        if s[i]=='Z':
            ans=cnt
    else:
        if s[i]=='A':
            flag=True
print(ans)

Solution (Python):
def resolve():
	s = input()
	a = len(s) - 1
	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)
resolve()

Solution (Python):
s = input()

f = s.find('A')
r = s.rfind('Z')

print(r-f+1)

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

Solution (Python):
def resolve():
    import re
    S = input()
    A = min([m.start() for m in re.finditer("A", S)])
    Z = max([m.start() for m in re.finditer("Z", S)])
    print(Z-A+1)

if '__main__' == __name__:
    resolve()

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

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

Solution (Python):
S = input()
start = end =  float("Inf")

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

print(len(S[start:end]))

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

Solution (Python):
s = input()
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
print(r - l + 1)

Solution (Python):
s = input()

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

Solution (Python):
import sys

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


def resolve():
    s = input()

    flg = False
    idx_A = 0
    idx_Z = -1
    for idx, i in enumerate(s):
        if i == "A" and not flg:
            idx_A = idx
            flg = True

        if i == "Z" and flg:
            idx_Z = idx

    print(max(0, idx_Z - idx_A + 1))


if __name__ == '__main__':
    resolve()

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

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

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

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1):
  if ltr == 'A' and flag == 0:
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
    pos_z = i
    if pos_z - (pos_a -1) > length:
      length = pos_z - (pos_a -1)
    else:
      flag = 0

print(length)

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

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

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

print(len(s) - right - left)

Solution (Python):
S = input()
ans = 0

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

for i in range(len(S)):
  if S[i]=="A":
    ans-=i
    break

print(ans)

Solution (Python):

s = input()

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = input()
    L = len(S)
    for i in range(L):
        if S[i] == 'A':
            left = i
            break
    for i in range(L-1,0,-1):
        if S[i] == 'Z':
            right = i
            break
    print(right-left+1)

if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    s=input()
    for i,a in enumerate(s):
        if a=='A':
            break
    for j in range(len(s)-1,-1,-1):
        if s[j]=='Z':
            break
    print(j-i+1)
        
if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()
def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
print(my_index_multi(S, "Z")[-1] - my_index_multi(S, "A")[0] + 1)

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

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

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

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

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

Solution (Python):
w = input()

print(w.rindex('Z')-w.index('A')+1)

Solution (Python):
s = input()
x = 0
y = 0
ans = 1

for c in s:
    if c == "A":
        break
    x += 1
  
for c in s[::-1]:  
    if c == "Z":
        break
    y += 1

print(len(s)-x-y)

Solution (Python):
s = input()

flg=-1
max = 0
for i in range(len(s)):
    if s[i]=="A" and flg==-1:
        a_index = i
        flg=1
        continue
    if s[i]=="Z":
        z_index = i

print((z_index-a_index)+1)

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

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

Solution (Python):
s = str(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
print(z-a+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, 0, -1):
  if s[i]=='Z':
    z=i
    break
print(z-a+1)

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

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

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()
ca = 0
cz = 0

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

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()

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

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

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

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()

pos_a = s.find('A')
pos_z = s.rfind('Z')

print(pos_z - pos_a + 1)

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

Solution (Python):
def resolve():
	s = list(input())
	b = -1
	e = -1
	for i in range(len(s)):
		if s[i] == 'A' and b < 0:
			b = i
		if s[i] == 'Z':
			e = i
	if b == -1 or e == -1:
		print(0)
	else:
		print(e-b+1)
resolve()

Solution (Python):
def main():
    S = input()
    L, R = 1001001, 0
    for i in range(len(S)):
        if S[i] == 'A' and L > i:
            L = i
        if S[i] == 'Z' and R < i:
            R = i
    print(R - L + 1)


if __name__ == '__main__':
    main()

Solution (Python):
import re
s = input()
r = re.compile(r'A.*Z')
q = r.search(s)
print(len(q.group()) if q != None else 0)

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

Solution (Python):
s=input()
l=len(s)
a=[]
z=[]
ans=0
for i in range(l):
    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()

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

Solution (Python):
s = input()

ans = 0
tmp = 0
flag = 0

for i, j in enumerate(s):
    if flag == 0 and j == 'A':
        tmp = i
        flag = 1
    elif flag == 1 and j == 'Z':
        ans = max(ans, i-tmp+1)
        flag = 2
    elif flag == 2:
        if j == 'Z':
            ans = max(ans, i-tmp+1)
        elif j == 'A':
            flag = 1

print(ans)

Solution (Python):
sss = input()
min_a = 0
max_s = 0
for i in range(len(sss)):
    if sss[i] == 'A':
        min_a = i
        break

for i in reversed(range(len(sss))):
    if sss[i] == 'Z':
        max_s = i
        break
print(max_s - min_a + 1)

Solution (Python):
s=input()

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

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

Solution (Python):
















S = input()

idxA = S.find("A") + 1
idxB = len(S) - S[::-1].find("Z")

ans = idxB - idxA + 1
print(ans)

Solution (Python):
s = list(input())
count_head = 0
count_tail = 0
for i in range(len(s)):
    if s[i] == "A":
        count_head = i
        break

for j in range(len(s)-1, count_head-1, -1):
    if s[j] == "Z":
        count_tail = j
        break

print(count_tail - count_head + 1)

Solution (Python):
s = str(input())
k = 1
a = 0
b = 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':
        b = i
        break

print(b - a + 1)

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

Solution (Python):
s = input()

a = 0
z = 0

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

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

print(z - a + 1)

Solution (Python):
list_S = list(input())
s = -1
e = -1
for i in range(len(list_S)):
    if list_S[i] == "A":
        s = i
        break

list_S.reverse()

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

print(e - s)

Solution (Python):

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

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

Solution (Python):
s = input()

s1 = s
s2 = s[::-1]

start = 0
end = 0

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

for i in range(len(s2)):
    if s2[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 = str(input())

cnt_A=0
cnt_Z=0
max=0
N=len(s)
for i in s:
	if i!='A':
		cnt_A+=1
	else:
		break

for i in range(-1,-200000,-1):
	if s[i]!='Z':
		pass
	else:
		break



print(N+(i+1)-cnt_A)

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

print(zp-ap+1)

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

Solution (Python):
S = input()
li = []
a = 0
cnt = 0
for i in range(len(S)):
    if a == 0 and S[i] == "A":
        a = 1
        cnt += 1
    elif a == 1 and S[i] == "Z":
        cnt += 1
        li.append(cnt)
    elif a == 1:
        cnt += 1
print(max(li))

Solution (Python):
s = input()

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

print(j - i + 1)

Solution (Python):
import re
regex = re.compile(r'A.*Z')

ans = 0
for res in regex.finditer(input()):
    ans = max(ans, len(res.group()))
    

print(ans)

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

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

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

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