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()
st = en = 0
for i in range(len(s)):
    if s[i] == "A":
        st = i
        break
for i in range(1,len(s)):
    if s[-i] == "Z":
        en = len(s) - i + 1
        break
print(en-st)

Solution (Python):
s=input()
S=len(s)
mi=[]
ma=[]
for i in range(S):
    if s[i]=='A':
        mi.append(i)
    elif s[i]=='Z':
        ma.append(i)
print(max(ma)-min(mi)+1)

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

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

Solution (Python):
s = str(input())
strFindA = ''
strFindZ = ''

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

for i in reversed(range(len(strFindA))):
  if strFindA[i] == "Z":
    strFindZ = strFindA[:i+1]
    break

print(len(strFindZ))

Solution (Python):
s = input()

first = s.index('A')
end = s.rindex('Z')

ans = end - first + 1
print(ans)

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

for i,j in enumerate(s):
    if j == 'A':
        a = i
        break
for i,j in enumerate(s):
    if j == 'Z':
        z = i
print(z-a+1)

Solution (Python):
s = input()
n = len(s)
a = 0
z = n - 1

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

for i in range(n):
    if s[i] == "Z":
        z = i

print(z - a + 1)

Solution (Python):
s = input()

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

length = end - first + 1
print(length)

Solution (Python):
s = input()

def first_A(s):
  for i in range(len(s)):
    if s[i] == "A":
      return i
    
def last_Z(s):
  for i in range(len(s)):
    if s[-(i+1)] == "Z":
      return -(i+1)+len(s)
    
print(last_Z(s) - first_A(s) + 1)

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

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

print(j + 1 - i)

Solution (Python):
def answer(s: str) -> int:
    return s.rfind('Z') - s.find('A') + 1


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


if __name__ == '__main__':
    main()

Solution (Python):
retu = input()
kari = 0
flag = False
for i in range(len(retu)):
    if flag:
        kari += 1
        if retu [i] == 'Z':
            an = kari
    elif retu[i] == 'A':
        flag = True
        kari += 1
print(an)

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

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    S = input()
    search_string=['A','Z']
    position=[]


    for i,s in enumerate(S):
        if s==search_string[0]:
            position.append(i)
            break


    for r_i,r_s in enumerate(reversed(S)):
        if r_s==search_string[1]:
            position.append(len(S)-r_i)
            break

    print(position[1]-position[0])

if __name__=="__main__":
    main()

Solution (Python):
s = input()
st = s.find("A")
for i in range(len(s)):
  n = len(s)-i-1
  t = s[n]
  if t == "Z":
    en = n
    break
print(en - st + 1)

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

for i in range(len(s)):
    if s[i] == "A":
        A = i
        break
for i in range(len(s)):
    if s[i] == "Z" and i > A:
        B = i

    
print(B - A + 1)

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

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

Solution (Python):
s = input()

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

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

print(len(s) - end - start + 1)

Solution (Python):
s = input()

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

Solution (Python):
S = input()
len = len(S)
start = len
end = 0
for i in range(len):
  if(S[i] == "A"):
    temp_start = i+1
    start = min(start,temp_start)
  if(S[i] == "Z"):
    temp_end = i+1
    end = max(end,temp_end)
print(end-start+1)

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

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

Solution (Python):
s = input()

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

for j, x in enumerate(s[::-1]):
    if x == "Z":
        break

print(len(s) - i - j)

Solution (Python):
s = input()
a_number = 0
z_number = 0

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

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

print(z_number - a_number + 1)

Solution (Python):
s = input()

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

Solution (Python):
s = input()
a_idx = None
for i, c in enumerate(list(s)):
    if c == 'A':
        a_idx = i
        break
z_idx = None
for i, c in enumerate(reversed(list(s))):
    if c == 'Z':
        z_idx = len(s) -i
        break
print(len(s[a_idx:z_idx]))

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

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

Solution (Python):
a=input()
b=a[::-1]
p=0

for i in range(len(a)):
  if a[0] !='A':
    a=a[1:]
  else:
    break
    
for i in range(len(a)):
  if a[-1] !='Z':
    a=a[:-1]
  else:
    break
    
    
print(len(a))

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

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

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

Solution (Python):
s = input()

max_len = 0
past = -1
for i in range(len(s)):
    if s[i] == 'A' and past == -1:
        past = i
        continue
    if s[i] == 'Z':
        max_len = max(max_len, i - past + 1)

print(max_len)

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

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

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


def read():
    s = input().strip()
    return s,


def solve(s):
    a, z = 0, len(s)-1
    while s[a] != "A":
        a += 1
    while s[z] != "Z":
        z -= 1
    return z-a+1


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Solution (Python):
s = str(input())
a = len(s)
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()
print((len(s)-s[::-1].index('Z'))-s.index('A'))

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

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

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

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

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

Solution (Python):
S = input()

left = -1

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

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

if left < right:
    print(right-left+1)

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

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

Solution (Python):
S = input()
a = 0
b = len(S) - 1
while 1:
  if S[a] == "A":
    break
  a += 1
while 1:
  if S[b] == "Z":
    break
  b -= 1
print(b - a + 1)

Solution (Python):
a=input()

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

Solution (Python):
a=input()

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

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

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

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

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

Solution (Python):
import math

b=input()
c=[]
for i in b:
    c.append(i)



a1=c[c.index("A"):]
a2=[i for i, x in enumerate(a1) if x=="Z"]
print(len(a1[:a2[-1]+1]))

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

while s[0] != 'A' or s[-1] != 'Z':
    if s[0] == 'A':
        s.pop()
    elif s[-1] == 'Z':
        s.pop(0)
    else:
        s.pop(0)
        s.pop()

print(len(s))

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

Solution (Python):
s = input()
n = len(s)
first, last = 0,0

for i in range(n):
  b,f = i+1, n-i
  if s[-1-i] == 'A':
    first = f
  if s[i] == 'Z':
    last = b


print(last - first+1)

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

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

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

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

print(en - st + 1)

Solution (Python):
s = input()
a = len(s)
z = 0
for i,e in enumerate(reversed(s)):
  if e == "A":
    a = len(s) - i -1 
for i,e in enumerate(s):
  if e == "Z":
    z = i

print(z-a+1)

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

A = s.index("A")

S = list(reversed(s))
Z = S.index("Z")

print(len(s) - Z - A)

Solution (Python):
s = input()
first = -1
end = 0
i = 0
for c in s:
    if first == -1 and c == 'A':
        first = i
    if c == "Z":
        end = i
    i += 1
print(end - first + 1)

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

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

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

Solution (Python):
s = input()

first_A_find = s.find("A")
end_Z_find = s.rfind("Z") + 1

print(end_Z_find - first_A_find)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    S = input()

    l = 0
    r = 0
    flag = False
    for i in range(len(S)):
        if not flag and S[i]=='A':
            l = i
            flag = True
        elif S[i]=='Z':
            r = i
    print(r - l + 1)


if __name__ == '__main__':
    main()

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

if __name__ == "__main__":
    solve()

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

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

Solution (Python):

data=list(input())
i=0
j=1
while data[i]!='A':
    i=i+1
while (data[-j]!='Z' and len(data)-j>i):
    j=j+1
print(len(data)-i-j+1)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
left = s.index('A')
right = s.rindex('Z')
print(right-left+1)

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



if __name__ == '__main__':
    main()

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

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

Solution (Python):
def main():
    s = input()
    a = len(s); z = 0
    for i, t in enumerate(s):
        if t == 'A':
            a = min(a, i)
        if t == 'Z':
            z = max(z, i)
    ans = z-a+1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()

    idx_a = s.index("A")
    idx_z = -1

    for i, char in enumerate(s):
        if char == "Z":
            idx_z = i

    print(idx_z - idx_a + 1)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
l = list(sys.stdin.readline().rstrip("\n"))
a = 10000000
z = 0
for i,s in enumerate(l):
    if s == 'A':
        a = min(a,i)
    if s == 'Z':
        z = i
print(z-a+1)

Solution (Python):
import re
s = input()
smax=0
res = re.search(r"A[A-Z]*Z",s)
print(len(res.group()))

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

Solution (Python):
s = input()

ind_A = 0
while s[ind_A] != 'A':
    ind_A += 1
ind_Z = len(s)
while s[ind_Z - 1] != 'Z':
    ind_Z -= 1

print(ind_Z - ind_A)

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

print(len(s)-a-b)

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

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

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

start=-1
last=-1

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

for j in reversed(range(0,len(S))):
  if S[j]=="Z":
    last=j
    break

print(last-start+1)

Solution (Python):
s = input()

st = len(s)
bk = 0
for i in range(len(s)):
    st = min(i, st) if s[i] == 'A' else st
    bk = max(i, bk) if s[i] == 'Z' else bk

print(bk - st + 1)

Solution (Python):

S = input()
a_index = 10**10
z_index = -1
for i in range(len(S)):
    if S[i] == "A":
        a_index = min(a_index, i)
    if S[i] == "Z":
        z_index = max(z_index, i)
print(z_index-a_index+1)

Solution (Python):
S = input()
start = S.find('A')
end = S.rfind('Z')
print(len(S[start:end])+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):
s = str(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)):
    if s[i] == 'Z':
        z_index = i

print(z_index - a_index + 1)

Solution (Python):
s=input();print(s.rindex('Z')-s.index('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':
    stop = len(s)-i
    break
ans = stop-start
print(ans)

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

s = s[::-1]


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

print(end-start)

Solution (Python):


s = list(input())

tmp_str =""
output=""
start_pos = end_pos = -1


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

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

if end_pos>=0 and start_pos>=0:
    length = end_pos - start_pos + 1
else:
    length = 0

print(length)

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

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

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

print(z_idx - a_idx + 1)

Solution (Python):



def main():
    s = input()
    i = s.find("A")
    j = s.rfind("Z")
    print(j - i + 1)


if __name__ == "__main__":
    main()

Solution (Python):



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


main()

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

Solution (Python):
s = input()
l = []
b = 0

for i in s:
    if b == 1:
        l.append(i)
    if i == 'A' and b == 0:
        l.append(i)
        b = 1

z = [i for i, x in enumerate(l, 1) if x == 'Z']
print(max(z))

Solution (Python):
s = input()

A_first_index = s.index('A')
Z_last_index = max([i for i, c in enumerate(s) if c == 'Z'])

print(len(s[A_first_index:Z_last_index+1]))

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

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

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

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

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

print(z - a + 1)

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

Solution (Python):
S = input()

for i in range(len(S)):
  if S[i] == 'A':
    top = i
    break
    
for j in reversed(range(len(S))):
  if S[j] == 'Z':
    tail = j
    break
    
print(j-i+1)

Solution (Python):
import re
s = str(input())
a = re.findall('A[A-Z]*Z', s)
print(max(map(len, a)))

Solution (Python):
s = input()

a = s.index('A')
z = list(reversed(s)).index('Z')

print(len(s)-z-a)

Solution (Python):

def main():
    s = list(input())
    start = 0
    end = 0

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


        
        
if __name__ == '__main__':
    main()

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


def main():
    s = input()
    l = len(s)
    forward = 0
    while s[forward] != "A": forward += 1
    back = -1
    while s[back] != 'Z': back -= 1
    print(l - forward + back + 1)

if __name__ == "__main__":
    main()

Solution (Python):
import re
s = str(input())
a = re.search(r'A[A-Z]*Z', s)
print(len(a.group()))

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

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

S=list(reversed(s))
for j in range(len(S)):
    if S[j]=="Z":
        z=j
        break

print(len(s)-a-z)

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

Solution (Python):
s=input()
l,d=[],[]
c=0
for i in s:
    if(i=='A'):
        l.append(c)
    if(i=='Z'):
        d.append(c)
    c+=1
print(max(d)-min(l)+1)

Solution (Python):
S=input()

i=0
A=[]
Z=[]
for s in S:
  if s=="A":
    A.append(i)
  elif s=="Z":
    Z.append(i)
  i=i+1
  
print(max(Z)+1-min(A))

Solution (Python):
s=input()
Acnt = 0
Zcnt = len(s)-1
while 1:
    if s[Acnt] == 'A':
        Acnt += 1
        break
    else:
        Acnt += 1
while 1:
    if s[Zcnt] == 'Z':
        Zcnt += 1
        break
    else:
        Zcnt -= 1
print(Zcnt-Acnt+1)

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

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

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

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):
sample = input()


a_pos = sample.index('A')

z_pos = sample.rfind('Z')
print(z_pos-a_pos+1)

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

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

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

Solution (Python):
s = input()
a_list = [i for i, x in enumerate(s) if x == 'A']
z_list = [i for i, x in enumerate(s) if x == 'Z']
a = a_list[0]
z = z_list[-1]
print(len(s[a:z+1]))

Solution (Python):
import re

letter = str(input())
pattern = 'A(.*)Z'
target = re.search(pattern, letter).group()
print(len(target))

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

print(y-x+1)

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

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

Solution (Python):
s = input()
flag = False
for i in range(len(s)):
    if not flag:
        if s[i] == 'A':
            p = i
            flag = True
    if flag:
        if s[i] == 'Z':
            q = i
print(q-p+1)

Solution (Python):

S = input()
a = S.find('A')
b = S.rfind('Z')
print(b - a + 1)

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

Solution (Python):
s = input()

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

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

print(j - i + 1)

Solution (Python):
s=input()
r_s=s[::-1]
c_a=s.find("A")
c_rz=r_s.find("Z")
c_z=len(s)-1-c_rz

print(c_z-c_a+1)

Solution (Python):
s = raw_input()
sinv = s[::-1]
z = len(s) -1 - sinv.find('Z')

print z - s.find('A')+1

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

Solution (Python):


S = str(input())
a_point = []
z_point = []

for i in range(len(S)):
    if S[i] == "A":
        a_point.append(i)
    if S[i] == "Z":
        z_point.append(i)

print(max(z_point)-min(a_point)+1)

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

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

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

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

Solution (Python):
s = input()
minA = 200000
maxZ = 0
for i in range(len(s)):
    if s[i] == "A":
        if i < minA:
            minA = i
    elif s[i] == "Z":
        if maxZ < i:
            maxZ = i

print(maxZ - minA + 1)

Solution (Python):

s = input()

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

s_ans = s[A:Z+1]
print(len(s_ans))

Solution (Python):
s = input()

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

print(pos_z -pos_a +1)

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()

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

if __name__ == "__main__":
    resolve()

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

Solution (Python):
string = input()
index_of_A = string.index("A")
index_of_Z = string.rfind("Z")

print(index_of_Z - index_of_A + 1)

Solution (Python):
s = input()

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

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

print(ans)

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

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

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

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

print(z-a+1)

Solution (Python):

s=list(str(input()))

nax=len(s)
first=0
last=nax
for i in range(nax):
    if s[i]=='A':
        first=i
        break
for i in range(nax):
    if s[nax-1-i]=='Z':
        last=nax-i-1
        break

print(last-first+1)

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """QWERTYASDFZXCV"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ZABCZ"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """HASFJGHOGAKZZFEGA"""
        output = """12"""
        self.assertIO(input, output)


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


if __name__ == "__main__":
     
     resolve()

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

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
print(len(s)-j-i)

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

Solution (Python):
S = input()
a = []
z = []
for i, s in enumerate(S):
    if s == "A":
        a.append(i)
    elif s == "Z":
        z.append(i)
print(z[-1]-a[0]+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()
print(S.rfind("Z") - S.find("A")+1)

Solution (Python):
s = input()
start = s.index('A')
end = s.rindex('Z')

print(end - start + 1)

Solution (Python):
S = input()

N = len(S)
Aflag = -1
Zflag = 0
for i in range(N):
    if Aflag == -1 and S[i] == 'A':
        Aflag = i
    elif S[i] == 'Z':
        Zflag = i

print(Zflag-Aflag+1)

Solution (Python):
if __name__ =='__main__':
    S = input()
    st = 0
    ed = 0
    cnt = 0
    flag = True
    for i, s in enumerate(S):
        if s=='A' and flag:
            st = i
            flag = False
        if s=='Z':
            ed = i
            cnt = max(cnt, ed-st)
    
    print(cnt+1)

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

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

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

Solution (Python):
s=input()

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

print(Z-A+1)

Solution (Python):
S = input()

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

print(Z-A)

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

	n = len(s)

	start = -1
	end = n

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


  
if __name__ == "__main__":
  	main()

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

	n = len(s)

	start = -1
	end = n

	for i in range(0, n, 1):
		if s[i] == "A":
			start = i
			break

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


  
if __name__ == "__main__":
  	main()

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

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







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

Solution (Python):
s = input()


start = []
finish = []

for i in range(len(s)):
    if s[i] == "A":
        start.append(i)
    elif s[i] == "Z":
        finish.append(i)
    else:
        pass

ans = finish[-1] - start[0] +1
print(ans)

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

count1 = 0
count2 = 0

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

for i in range(1, 200000 + 1):
    if S[-i] == "Z":
        count2 = i
        break

ans = len(S) - (count1 + count2) + 1
print(ans)

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

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

Solution (Python):
s = input()
temp = 10**9
x = []
y = []
for i in range(len(s)):
	if s[i] =="A":
		x.append(i)
	elif s[i]=="Z":
		y.append(i)

mx = min(x)
mz = max(y)


print((mz-mx)+1)