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()
a = s.index("A")
t = [i for i, x in enumerate(s) if x == "Z"]
b = t[-1]
print(b - a + 1)

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

Solution (Python):
s=input()

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

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

Solution (Python):
S = input().strip()
a = 10**9
z = 0
for i, s in enumerate(S):
    if s == "A":
        a = min(i, a)
    if s == "Z":
        z = max(i, z)
print(z-a+1)

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

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

ans = 0
flag = 0
a = 0

for i in range(len(s)):
    if flag != 1:
        if s[i] == "A":
            flag = 1
            a = i
    elif s[i] == "Z":
        ans = i-a+1

print(ans)

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

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

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

Solution (Python):
S = input()
N = len(S)
ans = 0
f = 0
b = 0

for i in range(N):
    if 'A' == S[i]:
        break
    else:
        f += 1
for i in range(1,N + 1):
    if 'Z' == S[-i]:
        break
    else:
        b += 1
b = N - b

ans = b - f
print(ans)

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

Solution (Python):
N=input()
N=list(str(N))
le=-1
ri=-1
for i in range(len(N)):
  if N[i]=="A":
    le=i
    break
for k in range(len(N)):
  if N[k]=="Z":
    ri=k
print(ri-le+1)

Solution (Python):
from collections import deque
s = deque(list(input()))
while True:
  if s.popleft()=="A":
    break
while True:
  if s.pop()=="Z":
    break
print(len(s)+2)

Solution (Python):
s = input()

a_i = s.index('A')
s1 = s[::-1]
z_i = s1.index('Z')

print((len(s)-z_i)-a_i)

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

Solution (Python):







s = input()

a = 500000000000
z = -1

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()
n=len(s)
k=s[::-1]
a=s.index("A")
z=n-k.index("Z")
print(z-a)

Solution (Python):
S = input()

st = 0
en = 0

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

for i in range(len(S)):
    if S[i] == "Z":
        en = i

print(en - st + 1)

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

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

S = input()

a_index = INF
b_index = 0
for i, s in enumerate(S):
    if a_index == INF and s == "A":
        a_index = i
    if s == "Z":
        b_index = i

ans = b_index - a_index + 1
print(ans)

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

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

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):
def main():
  s=str(input())
  print(s.rfind("Z") - s.find("A") + 1)
if __name__ == "__main__":
    main()

Solution (Python):
def main():
  s=str(input())
  l=len(s)
  f=None
  e=None
  for i in range(l):
    if s[i]=='A':
      f=i
      break
  for i in range(1,l):
    if s[-i]=='Z':
      e=l-i
      break
  print(e-f+1)
if __name__ == "__main__":
    main()

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

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

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

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

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

print(end-start+1)

Solution (Python):
def solve():
  S = input()
  a = S.find('A')
  z = S[::-1].find('Z')
  ans = len(S)-a-z
  return ans
print(solve())

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

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

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

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

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()

    start_index = s.find('A')

    s = s[::-1]

    end_index = len(s) - s.find('Z') - 1 

    print(end_index - start_index + 1)

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
st = s.index('A')
gl = [i for i,x in enumerate(s)if x == 'Z']

print(len(s[st:max(gl)])+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":
        goal=i
ans=goal-start
print(ans+1)

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

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

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

print(j-i+1)

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

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

Solution (Python):
S = input()

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    idx_a = s.index('A')
    idx_z = len(s) - s[::-1].index('Z') - 1

    print(idx_z - idx_a + 1)

if __name__ == '__main__':
    resolve()

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

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

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

Solution (Python):
s = input()

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

Solution (Python):
S=list(input())
length=len(S)
start=S.index('A')
M=list(reversed(S))
finish=M.index('Z')

print(length-start-finish)

Solution (Python):


def main():

    s = input()
    listS = list(s)
    n = len(listS)

    aIndex = 0
    zIndex = 0

    for i in range(n):
        if listS[i] == 'A':
            aIndex = i
            break

    for i in range(n):
        if listS[-(i + 1)] == 'Z':
            zIndex = n - i
            break

    ans = zIndex - aIndex

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
A_index = s.index('A')
s_r = list(reversed(s))
s_reverse = ''.join(s_r)
Z_index = s_reverse.index('Z')
ans = (len(s_reverse)-Z_index-1) - A_index + 1
print(ans)

Solution (Python):

s = input()

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

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

Solution (Python):
s = input()
n = len(s)
ma = n+1
mz = -1
for i in range(0 , n):
	if s[i]=='A':
		ma = min(ma, i)
	if s[i]=='Z':
		mz = max(mz, i)

if ma>mz:
	print(0)
else:
	print(mz-ma+1)

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

Solution (Python):
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  

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

Solution (Python):
din = str(input())
length = len(din)
first_A = -1
last_Z = -1
for i in range(length):
    if (din[i] == 'A' and first_A == -1):
        first_A = i
    elif din[i] == 'Z':
        last_Z = i
print(last_Z-first_A+1)

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

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

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()
ans=False
for i,v in enumerate(s):
    if ans==False:
        if v=="A":
            a=i
            ans=True
    else:
        if v=="Z":
            z=i
print(z-a+1)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    s = readline().strip()

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

    return


if __name__ == '__main__':
    main()

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

Solution (Python):
s=input()
 
ds=list(s)
 
 
c1=0
while ds[c1]!='A':
  c1+=1
 
c2=-1
while ds[c2]!='Z':
  c2-=1
 
print(len(s[c1:c2])+1)

Solution (Python):
from collections import deque
s=input()

ds=deque(s)
flag=True

while ds[0]!='A' or ds[-1]!='Z':
  if ds[0]!='A':
    ds.popleft()
  if ds[-1]!='Z':
    ds.pop()
print(len(ds))

Solution (Python):
s = input()

a_index = s.find('A')
z_index = s.rfind('Z')
new_s = s[a_index:z_index+1]
print(len(new_s))

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

Solution (Python):
s = open(0).read().rstrip()

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

print(m.end() - m.start())

Solution (Python):
sn = input()
r_sn = list(reversed(sn))
print(len(sn[sn.index("A"):len(sn)-r_sn.index("Z")]))

Solution (Python):
def main():
    s  = input()
    ind_a = 0
    ind_z = 0
    for i in range(len(s)):
        if(s[i]=="A"):
            ind_a = i
            break
    for i in range(len(s)-1,-1,-1):
        if(s[i]=="Z"):
            ind_z = i
            break



    print(ind_z-ind_a+1)
if __name__ == '__main__':
    main()

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

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

print(max(num2)-min(num1)+1)

Solution (Python):
MM = input()
listM = list(MM)
xx = len(listM)
saisyo =0
saigo  =xx
xx = len(listM)
for i in range(0,xx-1,1):
  
  if listM[i]=='A':
    saisyo = i
    
    break
for i in range(xx-1,0,-1):
  
  if listM[i]=='Z':
    saigo = i
    
    break
ans = saigo -saisyo
print(ans+1)

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

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

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

Solution (Python):
S = input()

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


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

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

Solution (Python):
s = input()

left = s.find("A")
right = s.rfind("Z")

print(right - left + 1)

Solution (Python):
s = input()

rs  = s[::-1]

inds = 0
indrs = 0

for i in range(len(s)):
    if s[i] == "A":
        inds = i
        break
    
for j in range(len(rs)):
    if rs[j] == "Z":
        indrs = j
        break

indrs = len(s) - indrs

print(abs(indrs - inds))

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

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

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

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

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

Solution (Python):
s = input()

answer = 0
a = 0
z = 0

words = list(s)

for num in range(len(words)):
    if words[num] == 'A':
        a = num
        break

for num in range(len(words)):
    if words[num] == 'Z':
        z = num

answer = z - a + 1

print(answer)

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input().strip()
    return S.rindex('Z')-S.index('A')+1


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

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):
s = input()
print(len(s[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[-(i + 1)] == 'Z':
    z = len(s) - 1 - i
    break
print(z - a + 1)

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

Solution (Python):
import sys
s = input()
for i in range(len(s) - 1):
    if s[i] == 'A':
        left = i
        break
for i in range(len(s) - 1, -1, -1):
    if s[i] == 'Z':
        print(i - left + 1)
        sys.exit()

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

Solution (Python):
s = input()

st = s.find("A")
ed = s.rfind("Z")

print(ed-st+1)

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

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

   
print((tmp2+1)-tmp1)

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

Solution (Python):

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

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

S = input().rstrip('\n')
print(S.rfind("Z") - S.find("A") + 1)

Solution (Python):
s = input()
for i, st in enumerate(s):
    if st=='A':
        start = i
        break
for i, st in enumerate(s):
    if st=='Z':
        end = i
print(end-start+1)

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

Solution (Python):
s=input()


num_a=s.index("A")


num_z=len(s)-1-s[::-1].index("Z")

print(num_z-num_a+1)

Solution (Python):
s = input()

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

Solution (Python):
s = input()

left = s.index('A')+1
right = len(s)-s[::-1].index('Z')

ans = right - left + 1
print(ans)

Solution (Python):
s=input()
a=int(len(s))
z=0
for i in range(int(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):
s = input()
s_start = 0
s_end = 0
count = 0


s_reverse = s[::-1]


for i in s:
    if i == 'A':
        s_start = count
        break
    count += 1


count = len(s) - 1

for j in s_reverse:
    if j == 'Z':
        s_end = count
        break
    count -= 1

ans = s_end - s_start + 1
print(ans)

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

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

print(ind_z-ind_a+1)

Solution (Python):
s=input()

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

print(z-a+1)

Solution (Python):
s = input()

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

Solution (Python):
S = input()
s = S.index('A')
e = [i for i, x in enumerate(S) if x == 'Z']

print(max(e) - s + 1)

Solution (Python):
s = input()

anum = 0
while s[anum] != "A":
    anum += 1
znum = len(s)-1
while s[znum] !="Z":
    znum -= 1

print(znum - anum +1)

Solution (Python):

S = str(input())
l = len(S)
st = 0
en = 0
for i in range(l):
    if S[i] == 'A':
        st = i
        break
for j in range(l-1,-1,-1):
    
    if S[j] == 'Z':
        en = j
        break

print(en-st+1)

Solution (Python):
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


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


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

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

print(z - a + 1)

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

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

Solution (Python):
s = input()
ans = 0
cnt = 0
left = 200005
right = 0
for i in range(len(s)):
    if (s[i]=='A') : 
        left = min(left, i)
    if (s[i]  == "Z") :
        right = max(right, i)
print(right - left+1)

Solution (Python):

s = input()
A, Z = None, None
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()
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):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    s = input()
    a = []
    z = []
    for i, c in enumerate(s):
        if c == 'A':
            a.append(i)
        if c == 'Z':
            z.append(i)
    
    print(z[-1]-a[0]+1)


t = 1

for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""

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

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

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

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

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

f = ''
for i in s:
  if f == '':  
    if i == 'A':
      f = s.index(i)
  else:
    break  

for i in range(len(s)):
  if s[i] == 'Z':
    e = i

print(e - int(f) + 1)

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

f=s.index("A")
l=s_r.index("Z")
l_r=len(s)-1-l


print(l_r-f+1)

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

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

Solution (Python):
S = input()
T = S[::-1]

for n in range(len(S)):
  if S[n]=="A":
    a=n
    break

for m in range(len(T)):
  if T[m]=="Z":
    z=len(S)-m
    break
    
print(z-a)

Solution (Python):
s = input()

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

Solution (Python):


s = list(str(input()))

a_start = 0
z_end = 0


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


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

print(len(s[a_start:z_end+1]))

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

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

ans = 0
count = 0
flag = False
for s in S:
    if flag:
        count += 1
        if s == "Z":
            ans = count
    else:
        if s == "A":
            flag = True
            count += 1

print(ans)

Solution (Python):
s = input()
 
first_A = None
last_Z = None
for i, c in enumerate(s):
    if c == 'A' and first_A is None:
        first_A = i
    if c == 'Z':
        last_Z = i
 
print(last_Z-first_A+1)

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

Solution (Python):
s = input()
start_i, end_i = 0, 0
a_flag = True

for i, c in enumerate(s):
  if c == 'A' and a_flag:
    start_i = i
    a_flag = False
  if c == 'Z':
    end_i = i
    
print(end_i - start_i + 1)

Solution (Python):
s = input()

a = s.find('A')

z = 0
for i in range(len(s)):
  if s[i] == 'Z':
    z = i

print(z-a+1)

Solution (Python):
s = input()
amin = 10000000000
amax = -1

for i, j in enumerate(s):
    if j=="A":
        amin = min(amin, i)
    elif j=="Z":
        amax = max(amax, i)
    
print(amax-amin+1)

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

Solution (Python):
s = input()

a=[]
b=[]

for i in range(len(s)):
    if s[i]=="A":
        a.append(i)
    elif s[i]=="Z":
        b.append(i)

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

print(y-x+1)

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

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

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

Solution (Python):
s = input()

first_A = None
last_Z = None
for i, c in enumerate(s):
    if c == 'A' and first_A is None:
        first_A = i
    if c == 'Z':
        last_Z = i

print(last_Z-first_A+1)

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

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

Solution (Python):
s=input()
f1=0
f2=0
ok=True
for i in range(len(s)):
    if s[i]=='A' and ok:
        ok=False
        f1=i
    if s[i]=='Z': f2=i
print(f2-f1+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):
s=input();s2=s[::-1];print(len(s)-(s.index('A')+s2.index('Z')))

Solution (Python):
s = input()

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

print(z-a+1)

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

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

front = s.index("A")
s.reverse()
back = s.index("Z")

print(len(s)-front-back)

Solution (Python):
import sys
import re
s = str(input())
if len(s) < 0 or len(s) > 200000:
    sys.exit()

array_str = re.findall(r'A.*Z', s)
max = 0
for I in array_str:
    if len(I) > max:
        max = len(I)
print(max)

Solution (Python):






s = input()
print(len(s) - list(reversed(s)).index("Z") - s.index("A"))

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

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

Solution (Python):
S=input()
start=0
last=0
for i in range(len(S)):
    if S[i]=='A':
        start=i
        break

for j in range(1,len(S)+1):
    if S[-j]=='Z':
        last=len(S)-j
        break
    
print(last-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)
print(max(z) - min(a) + 1)

Solution (Python):
s = str.upper(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 = list(input())
Z_place = 0
A_place = s.index('A')

for i in s[:A_place:-1]:
     if i != 'Z':
        Z_place += 1
     else:
         break

print(len(s) - (A_place + Z_place))

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

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

j = 1
while s[l-j] != "Z":
    j += 1

print(l-j-i+1)

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

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

Solution (Python):
S = input()
l = len(S)
r = -1

for i, s in enumerate(S):
    if s == 'A':
        l = min(l, i)
    if s == 'Z':
        r = max(r, i)

print(r - l + 1)

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

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

for i in range(len(s)):
  if s[i]=="A":
    for j in range(1,len(s)):
      if s[-1*j]=="Z":
        print(len(s)-i-j+1)
        sys.exit()

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)