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()
m = re.search(r'A.*Z', s)
print(len(m.group()))

Solution (Python):
s=input()
Acnt=[];Zcnt=[]
for i in range(len(s)):
    if(s[i]=='A'):
        Acnt.append(i)
    elif(s[i]=='Z'):
        Zcnt.append(i)
print(Zcnt[-1]-Acnt[0]+1)

Solution (Python):
s = input()

start = min(i for i, x in enumerate(s) if x == 'A')
end = max(j for j, y in enumerate(s) if y == 'Z')

print(end-start+1)

Solution (Python):
S = input()
resA=0
resZ=0
for i in range(1,len(S)+1):
	if S[i-1]=='A' and resA==0:
		resA=i
	elif S[i-1]=='Z':
		resZ=i
if resA !=0 and resZ !=0:
	print(resZ-resA+1)
else:
	print(0)

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

Solution (Python):
N = input()
Nreverse = N[::-1]
for i in range(len(N)):
    if N[i] == "A":
        Initial = i+1
        break
for j in range(len(Nreverse)):
    if Nreverse[j] == "Z":
        Final = len(N)-j
        break

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

print(end-start+1)

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

Solution (Python):
m = input()

A = m.index("A")
Z = m.rfind("Z")

print(Z-A+1)

Solution (Python):
icase=0
if icase==0:
    s=list(input())
    ss=[]
    for i in range(len(s)):
        ss.append([s[i],i])
    ss.sort()
    print(ss[-1][1]-ss[0][1]+1)

Solution (Python):
def myAnswer2(s:str) -> int:
   return len(s)-s[::-1].index("Z") - s.index("A")

def main():
   s = (input())
   print(myAnswer2(s))

if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer2(s:str) -> int:
   return len(s)-s[::-1].index("Z") - s.index("A")

def main():
   s = (input())
   print(myAnswer2(s))

if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer(s:str) -> int:
   start = 0
   end = 0
   for n,string in enumerate(s):
      if(string =="A"):
         start = n
         break
   for n,string in enumerate(s[::-1]):
      if(string == "Z"):
         end = len(s) - n
         break
   return end - start





def modelAnswer():
   tmp=1
def main():
   s = (input())
   print(myAnswer(s))

if __name__ == '__main__':
   main()

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

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

Solution (Python):
from collections import deque
s=deque(list(input()))
while True:
    if s[0]!="A":
        s.popleft()
    else:
        break
while True:
    if s[-1]!="Z":
        s.pop()
    else:
        break

print(len(s))

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

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

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

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

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

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

Solution (Python):
s = input()
a, z = 0, 0

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

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

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

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

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

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

Solution (Python):
s=input()

inda=-1
indz=0
for i in range(len(s)):
  if s[i] =="A" and inda==-1:
    inda=i
  if s[i]=="Z":
    indz=i
print(indz-inda+1)

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 = i
        break
    
print(len(s) - start - end)

Solution (Python):
s = input()

l = s.index('A')
r = s.rindex('Z')

print(r-l+1)

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()

a = inf
z = -inf
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()
n = len(s)
for i in range(n):
    if s[i] == "A":
        l = i
        break

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

ans = max(0,r-l)
print(ans)

Solution (Python):
s = input()

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

print(z - a + 1)

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

Solution (Python):
s = input()

A = []
Z = []
for i, si in enumerate(s):
    if si == 'A':
        A.append(i)
    elif si == 'Z':
        Z.append(i)

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

Solution (Python):
s = input()
lis_A = []
lis_z = []

for num,moji in enumerate(s):
    if 'A' == moji:
        lis_A.append((num,moji))
    elif 'Z' == moji:
        lis_z.append((num,moji))

print(max(lis_z)[0] - min(lis_A)[0] + 1)

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

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

a = [n for n,v in enumerate(s) if v == "A"]
z = [n for n,v in enumerate(s) if v == "Z"]

b = min(a)
y = max(z)

print(y-b+1)

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

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

m = re.search(r'A.*Z', s)

print(len(m.group()))

Solution (Python):
s=input()
m=s.find("A")
n=s.rfind("Z")
if m<n:
    ans=(n-m)+1
    print(ans)
else:
    pass

Solution (Python):




s = input()


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

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

ans = zidx - aidx + 1


print(ans)

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

Solution (Python):
s = input()

k = s[::-1]

for i in range(len(s)):
    if s[i]=='Z':
        z_num = i 
    if k[i]=='A':
        a_num = i

ans = a_num + z_num + 2 - len(s)

print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline


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

    idx_A = s.find("A")
    idx_Z = (len(s) - 1) - s[::-1].find("Z")
    ans = idx_Z - idx_A + 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


s = input()
n = len(s)
left = 0
flag1 = True
right = n
flag2 = True
for i in range(n):
    if s[i] == "A" and flag1:
        left = i
        flag1 = False
    if s[n - i - 1] == "Z" and flag2:
        right = n - i - 1
        flag2 = False


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

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

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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


if __name__ == '__main__':
    main()

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

print(s)

Solution (Python):
s = input()
ans = 0
tmp_ans = 0
flag = False

for char in s:
    if not flag:
        if char == "A":
            flag = True
            tmp_ans += 1
    else:
        tmp_ans += 1
        if char == "Z":
            ans = tmp_ans

print(ans)

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

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

Solution (Python):
import numpy as np
import sys
readline = sys.stdin.buffer.readline


S=input()


i=S.index('A')


S1 = S[::-1]

j=(S1.index('Z'))
j=len(S)-j



print(j-i)

Solution (Python):
s = input()

import re
pattern = r'A.*Z'
match = re.findall(pattern, s)

cnt = len(match[0])
print(int(cnt))

Solution (Python):
import itertools
s = list(input())
s1 = list(itertools.dropwhile(lambda x: x != 'A',s))
s2 = list(itertools.dropwhile(lambda x: x != 'Z',s1[::-1]))
print(len(s2))

Solution (Python):
s = input()
a = s.index('A')
zl = [i for i, x in enumerate(s) if x == 'Z']
z = zl[len(zl)-1]
print(z-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):
import re
a=input()
m=a.find("A")
n=a.rfind("Z")
print(n-m+1)

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

for i in range(n):
    if s[i]=="A":
        top=i
        break
q=s[::-1]

for i in range(n):
    if q[i]=="Z":
        bottom=n-i-1
        break
        
print(bottom-top+1)

Solution (Python):
s = input()
l = 0
r = 0
seen = False
for i in range(len(s)):
  if not seen and s[i] == 'A':
    l = i
    seen = True
  elif s[i] == 'Z':
    r = i
print(r-l+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,a,-1):
    if s[i] == 'Z':
        z = i
        break
print(z-a+1)

Solution (Python):

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

Solution (Python):
s = input()
a = s.index("A")
b = 0
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):
s = input()
t = s[::-1]
 
for i in range(len(s)):
  if s[i] == "A":
    break
for j in range(len(t)):
  if t[j] == "Z":
    break
if j != 0:
  print(len(s[i:-j]))
if j == 0:
  print(len(s[i:]))

Solution (Python):
import sys
s = list(input())
a=0
b=0
frag=True
for i in range(len(s)):
    if (s[i]=='A')and frag :
        a=i  
        frag=False
    elif s[i]=='Z':
        b=i


print(b-a+1)

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

Solution (Python):
s = input()
x = len(s)
y = 0
z = 0
a = x - 1
while(y <= x):
  if (s[y] == "A"):
    z = y
    break
  y += 1
while(y <= x):
  if (s[a]  == "Z"):
    print(str(a - z + 1))
    break
  a -= 1
  y += 1

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

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

Solution (Python):
S = input()

A_index = 0
Z_index = 0

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

Solution (Python):
s =input()
A=0
Z=0

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

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

Solution (Python):
S = input()
s = [i for i in S]
a = S.find('A')
b = S.rfind('Z') - (a-1)
del s[:a]
del s[b:]
print(len(s))

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

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

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

ans1 = 0
ans2 = 0

for i in range(len(a)):
		if a[i] == 'A':
			ans1 = i
			break
for j in reversed(range(len(a))):
		if a[j] == 'Z':
			ans2 = j
			break

print(ans2 - ans1 +1)

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

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

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

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

Solution (Python):
s=input()

s = list(s)

memo1=10000000000000000000000

ans = 0

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

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

Solution (Python):




"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""





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

Solution (Python):


s = input()

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

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

for i, j in enumerate(s):
    if j == "A":
        temp = i
        break
for i, j in enumerate(reversed(s)):
    if j == "Z":
        temp2 = len(s) - i
        break

print(len("".join(s[temp:temp2])))

Solution (Python):
s = list(input())
a = s.index('A')
s.reverse()
b = s.index('Z')
c = len(s) -b
print(c-a)

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

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

for i in range(n-1,-1,-1):
    if s[i] == "Z":
        print(i-a+1)
        exit()

Solution (Python):
line = input()
num = len(line)
dust = []
for i in line:
  if i != "A":
    dust.append(i)
  else:
    break
for j in reversed(line):
  if j != "Z":
    dust.append(j)
  else:
    break
answer = num - len(dust)
print(answer)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
L = len(S)
a = -1
for i in range(L):
    if S[i] == 'A':
        a = i
        break

z = -1
for i in range(L):
    if S[-(i + 1)] == 'Z':
        z = i
        break

print(L - z - a)

Solution (Python):
s = input()
n = len(s)
for i in range(n):
    if s[i] == "A":
        an = i
        break

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

print(zn-an+1)

Solution (Python):
s=input()
for i,j in enumerate(s):
    if j=="Z":
        ans=i
for i,j in enumerate(s):
    if j=="A":
        ans-=i-1
        break
print(ans)

Solution (Python):
s=input()
fdl=s.find("A")
fdr=s.rfind("Z")

print((fdr-fdl)+1)

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

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

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

Solution (Python):
S = input()

first_i_a = S.find('A')
last_i_z = S.rfind('Z')
len_AZ = last_i_z - first_i_a + 1
print(len_AZ)

Solution (Python):



s = input()


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

Solution (Python):
s=input()
x=0;y=0
for i in range(len(s)):
  if s[i]=="A":
    x=i+1
    break
t=s[::-1]
for i in range(len(t)):
  if t[i]=="Z":
    y=len(s)-i
    break

print(y-x+1)

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

Solution (Python):
s=input()

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

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

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

print(ans)

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

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

Solution (Python):
s = list(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()
pos=-1
ans=0
for i,c in enumerate(s):
    if c=='Z' and pos!=-1:
        ans=max(ans,i-pos+1)
    if c=='A' and pos==-1:
        pos=i
print(ans)

Solution (Python):
s = input()

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

print(end-start+1)

Solution (Python):
s = input()

start = s.index("A")
goal = [i for i,x in enumerate(s) if x == "Z"][-1]

print(goal - start + 1)

Solution (Python):

import math
import itertools
import statistics

s = input()
start = -1
end = -1

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


print(end-start+1)

Solution (Python):
s = input()
a = len(s)
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 = list(input())
sr = s[::-1]

print((len(s)-sr.index("Z")) - s.index("A"))

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

Solution (Python):
s = input()
ans=0
j=1
for i in range(len(s)):
    if s[i]=="A":
        while s[-j] != "Z":
            j += 1
        ans = len(s)-j-i+1
        break
    else:
        continue

print(ans)

Solution (Python):

s=input()

num = -1
for ss in s:
    num +=1
    if ss == "A":
        a=num
        break

num=0
for ss in reversed(s):
    num -=1
    if ss == "Z":
        z=num
        break

len=len(s[a:z])
print(len+1)

Solution (Python):

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

Solution (Python):
S = input()
a_min_ind = None
for i, s in enumerate(S):
    if s == 'A' and a_min_ind is None:
        a_min_ind = i
    if s == 'Z':
        z_max_ind = i

print(z_max_ind - a_min_ind + 1)

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

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

print(j-i+1)

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

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

Solution (Python):
s = input()

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

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

print(end-start+1)

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

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

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

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

Solution (Python):
s , e = -1 , 0
c =  0
for i in input():
    if i == 'A':
        if s == -1:
            s = c
        
    if i == 'Z':
        e = c

    c += 1

print(e-s+1)

Solution (Python):
s = input()

i = 0
while True:
    if s[i] == "A":
        a = i
        break
    i = i + 1

i = -1
while True:
    if s[i] == "Z":
        z = i
        break
    i = i - 1

ans = len(s) - a + (z + 1)
print(ans)

Solution (Python):
s= input()

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

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
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 fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

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

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    S = input().strip()
    l = -1
    for i in range(len(S)):
        if S[i] == "A":
            l = i
            break
    for i in range(len(S)):
        if S[-(i+1)] == "Z":
            r = len(S)-i
            break
    print(r-l)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):

s = input()

l = 20000000
r = 0
for i in range(len(s)):
    if s[i] == 'A' and l >= i:
        l = i
    elif s[i] == 'Z' and i >= r:
        r = i
        
print(r-l+1)

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

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

Solution (Python):
import sys

s = input()

a_index = s.find("A")
z_index = s.rfind("Z")

print("{}".format(z_index - a_index + 1))

Solution (Python):
s = input()

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

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

Solution (Python):
import sys

s = input()
c = 0
C = 0

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

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

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

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

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

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

Solution (Python):
s=input()
a,b,n=-1,-1,len(s)
for i in range(n):
  a=i if a<0 and s[i]=='A' else a
  b=n-1-i if b<0 and s[n-1-i]=='Z' else b
print(b-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(1,len(s)):
    t = -i
    if s[t] == 'Z':
        end = t+1
        break

ans = len(s) + end - start
print(ans)

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

Solution (Python):



s = input().rstrip()

a_index = -1
b_index = -1

for i in range(len(s)):
    if s[i] == "A":
        if a_index < 0:
            a_index = i
    elif s[i] == "Z":
        b_index = i

print(b_index-a_index+1)

Solution (Python):


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    a=s.find("A")
    z=s.rfind("Z")
    print(z-a+1)
    

main()

Solution (Python):








def resolve():
    S=list(input())
    print(len(S[S.index('A'):[i for i ,x in enumerate(S) if x == 'Z'][-1]+1]))


resolve()

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