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()
l = len(s)
idx_a = 0
idx_z = 0
for n in range(l):
    if s[l-n-1] == 'A':
        idx_a = l-n-1
    if s[n] == 'Z':
        idx_z = n
    
print(idx_z-idx_a+1)

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

Solution (Python):
s = input()
ai, zi = None, 0
for i in range(len(s)):
    if ai is None and s[i] == 'A':
        ai = i

    if s[i] == 'Z':
        zi = i

print(zi - ai + 1)

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

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

ans = endZ - startA +1
print(ans)

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

Solution (Python):
s=input()

a=s.find("A")
s=s[::-1]

z=len(s)-s.find("Z")-1



print(z-a+1)

Solution (Python):
s = input()

a_index = []
for id, chr in enumerate(s):
    if chr == 'A':
        a_index.append(id)

z_index = []
for id, chr in enumerate(s):
    if chr == 'Z':
        z_index.append(id)

print(z_index[-1] - a_index[0] + 1)

Solution (Python):
from sys import stdin
s = (stdin.readline().rstrip())
A = 10**9
Z = -10**9
for ind,i in enumerate(s):
    if i == "A" and ind < A:
        A = ind
    if i == "Z" and ind > Z:
        Z = ind
print(Z-A+1)

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

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

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

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

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

Solution (Python):



def main():
    s = input()

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

    
    
    
    


if __name__ == "__main__":

    main()

Solution (Python):
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i + 1
    elif s == 'Z':
        max_Z = i + 1

print(max_Z - min_A + 1)

Solution (Python):
s = input()
lst_a = []
lst_z = []

for i in range(len(s)):
    if (s[i] == 'A'):
        lst_a.append(i)
    if (s[i] == 'Z'):
        lst_z.append(i)

a = min(lst_a)
z = max(lst_z)
print(z-a+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):
row = input().split()
s = list(row[0])
Flag = 0
count = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        Flag = 1
    if s[i] == 'Z' and Flag == 1:
        ans = count

    if Flag == 1:
        count += 1

print(ans+1)

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

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()

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

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

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

S_size = len(S)

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

for i in reversed(range(S_size)):
    if S[i] == 'Z':
        stop = i 
        break

print(stop - start + 1)

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

Solution (Python):



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

Solution (Python):













































S_list = list(input())
l = len(S_list)
for i in range(l):
    if S_list[i] == "A":
        start = i
        break
for i in range(l):
    if S_list[i] == "Z":
        finish = i


print(finish - start + 1)

Solution (Python):
S_list = list(input())
l = len(S_list)
for i in range(l):
    if S_list[i] == "A":
        start = i
        break
for i in range(l):
    if S_list[i] == "Z":
        finish = i


print(finish - start + 1)

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

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

Solution (Python):
S = input()
ans = 0
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()
ans = 0
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()
A1=S.find("A")
A2=S.rfind("Z")
print(A2-A1+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,-1,-1):
    if S[i]=="Z":
        b=i
        break
print(b-a+1)

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

S = s()

A = S.find('A')
for i in range(len(S)):
    if S[-i-1] == 'Z':
        print(len(S) - i - A)
        import sys
        sys.exit()

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

Solution (Python):
s = input()
first = -1
last = -1
for i in range(0,len(s)):
    if s[i] == "A" and first == -1:
        first = i
    if s[i] == "Z":
        last = i
print(int(last - first + 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):
a = input()
b = 0
count = 0
d = 0 
e = []
flag = False
for i in a:
     if i == "A" and d == 0:
          b = count
          flag = True
          d += 1
     if i == "Z":
          e.append(count)
     count += 1
print(e[-1]-b+1)

Solution (Python):
s = input()
a = 0
ga = 0
b = 0
gb = 0
for i in s:
    a = a+1
    if i == "A":
        ga = a 
        break


for i in s:
    b = b+1
    if i == "Z":
        gb = b


print(gb-ga+1)

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

Solution (Python):
s=input()

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

Solution (Python):
s = input()
left = 0
right = 0

for idx, val in enumerate(s):
        if val == 'A':
                left = idx
                break

for idx, val in enumerate(reversed(s)):
        if val == 'Z':
                right = idx
                break

print(len(s) - left - right)

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

Solution (Python):
s = input()

a_no = 0
z_no = 0

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

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


abc()

Solution (Python):


import sys


s = tuple(sys.stdin.readline().rstrip())

length = len(s)



minA = length
maxZ = 0

for i in range(length):
  
  if i < minA and s[i] == "A":
    minA = i
  
  if s[i] == "Z":
    maxZ = i

print(maxZ - minA + 1)

Solution (Python):

strings = list(input())


place_smallest_A= 200000
place_largest_Z= 0


for number in range(len(strings)):
  if strings[number] == "A":
    if number < place_smallest_A:
      place_smallest_A = number
      

for number in range(len(strings)):
  if strings[number] == "Z":
    if number > place_smallest_A:
      place_smallest_Z = number


ans = strings[place_smallest_A:place_smallest_Z+1]

print(len(ans))

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(max(z)-min(a)+1)

Solution (Python):
S = input()
s = 0
e = 0

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

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

sys.setrecursionlimit(2147483647)
INF = float("inf")



S = sys.stdin.readline().rstrip()
l = S.index('A')
r = S.rindex('Z')
print(r-l+1)

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

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

Solution (Python):
s = list(input())
aa = []
zz = []
for i, j in enumerate(s):
    if j == 'A':
        aa.append(i)
    elif j == 'Z':
        zz.append(i)

l = min(aa)
r = max(zz)

print(len(s[l:r])+1)

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

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

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

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)

a = min(a)
z = max(z)

if z<=a:
    print('0')
else:
    print(len(S[a:z+1]))

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

Solution (Python):
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    a = 0
    flagA = True


i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)

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

Solution (Python):
s = input()
st = s.find("A")
en = "".join(reversed(list(s))).find("Z")
print((len(s) - en) -st)

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

Solution (Python):
from sys import stdin
s = stdin.readline().rstrip()
si, ei = 0, 0
a_marked = False
for i, c in enumerate(s):
    if c == 'A':
        if a_marked:
            continue
        else:
            si = i
            a_marked = True
    if c == 'Z':
        ei = i
print(len(s[si:ei+1]))

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

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

Solution (Python):
s = input()
start = s.find("A")
end = len(s) - s[::-1].find("Z")

print(end - start)

Solution (Python):
s = input()
t = list(reversed(s))
for i in s:
    if i == "A":
        a = s.index(i)
        break
for j in t:
    if j == "Z":
        z = t.index(j)
        break
print(len(s) - z - a)

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

Solution (Python):
s = input()

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

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

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

a=[]
z=[]

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

    if s[i]=="Z":
        z.append(i)

a=min(a)
z=max(z)

if z<=a:
    print("0")
else:
    print(len(s[a:z+1]))

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

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

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

print(z-a+1)

Solution (Python):
S = input()
a = S.find('A')

b = S[::-1].find('Z')

print(len(S)-a-b)

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

a = min(a_left) 
z = max(z_right) + 1
print("{}".format(z - a))

Solution (Python):


def solve():
    s = input()

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

    print(len(s[a_i:z_i+1]))

if __name__ == "__main__":
    solve()

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

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

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

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

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

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

Solution (Python):


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

s = s[::-1]

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

Solution (Python):
if __name__ == '__main__':
    s = str(input())

    A_indexes = []
    Z_indexes = []

    for i in range(len(s)):
        if s[i] == "A":
            A_indexes.append(i)
        if s[i] == "Z":
            Z_indexes.append(i)

    print(max(Z_indexes)-min(A_indexes)+1)

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

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

Solution (Python):

"""
B - A to Z String
https://atcoder.jp/contests/abc053/tasks/abc053_b

"""
import sys


def solve(s):
    A_positions = []
    Z_positions = []
    for i, ch in enumerate(s):
        if ch == 'A':
            A_positions.append(i)
        elif ch == 'Z':
            Z_positions.append(i)
    return Z_positions[-1] - A_positions[0] + 1


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

Solution (Python):

def main():
    s = input()
    s_answer = s[s.index("A"):s.rindex("Z") + 1]
    print(len(s_answer))


if __name__ == "__main__":
    main()

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

a = s.index("A")
s.reverse()
z = s.index("Z")

print(len(s) - z - a)

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,-1,-1):
	if s[i] == "Z":
		r = i
		break
print(r-l+1)

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

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

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

Solution (Python):
s=input()
flag1=0

for i in range(len(s)):
    if s[i]=='A' and flag1==0:
        start=i
        flag1=1
    elif s[i]=='Z' and flag1==1:
        finish=i

print(finish-start+1)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

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

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a is None:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)

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

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

Solution (Python):
s = input()
r = s[::-1]
k = 0
l = 0
while s[k] != 'A':
	k += 1
while r[l] != 'Z':
	l += 1
print(len(s) - k - l)

Solution (Python):
string=input()

tmp=None
a=[]
for i in range(len(string)):
    if string[i]=="A" and tmp is None:
        tmp=i
    if string[i]=="Z" and tmp is not None:
        a.append(i-tmp+1)
print(max(a))

Solution (Python):
s = input()

index_A = float('inf')
index_Z = -1

for i in range(len(s)):
    if s[i] == 'A':
        if i < index_A:
            index_A = i
    elif s[i] == 'Z':
        if i > index_Z:
            index_Z = i

print(index_Z - index_A + 1)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    slen = len(s)

    firstx = -1
    lastz = slen

    for i in range(slen):
        if firstx == -1 and s[i] == 'A':
            firstx = i
        if s[i] == 'Z':
            lastz = i
    
    print(lastz - firstx +1)
    
solve()

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()
s_list = []
for i in s:
    s_list.append(i)
for j in range(len(s_list)):
    if s_list[j] == "A":
        A_first = j
        break
s_list = s_list[::-1]
for k in range(len(s_list)):
    if s_list[k] == "Z":
        Z_last = k
        break

print(len(s_list) - (A_first) - (Z_last))

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

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

Solution (Python):
from fractions import *
s = input()

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

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

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

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

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

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

Solution (Python):
S = list(input())
st = len(S)
ed = 0
for i in range(len(S)):
    if (S[i] == 'A'):
        st = min(i, st)
    if (S[i] == 'Z'):
        ed = i
ans = ed - st + 1
print(ans)

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

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

Solution (Python):
s = input()

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

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

ans = s[i:j+1]
print(len(ans))

Solution (Python):
s = input()

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

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

ans = s[i:j+1]
print(len(ans))

Solution (Python):
S = input()

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

Solution (Python):
s = input()

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

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

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

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

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

Solution (Python):
s = list(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()
ans = 0
x = -1
for i in s:
    if i == 'A' and x == -1:
        x = 0
    if x >= 0:
        ans += 1
        x += 1
        if i == 'Z':
            x = 0

print(ans - x)

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

Solution (Python):
N=list(input())
n=len(N)
X=0
for i in range(n):
  if N[i]=="A" :
    X=i
    break
for i in range(n):
  if N[-(i+1)]=="Z" :
    X+=i  
    break
print(n-X)

Solution (Python):
N=list(input())
n=len(N)
M=0
X=Y=0
for i in N:
  M+=1
  if i=="A" :
    X=M
    break
M=0
for i in N[::-1]:
  M+=1
  if i=="Z":
    Y=M
    break
print(n+2-X-Y)

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

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

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

Solution (Python):
from sys import stdin


def main():
    s = stdin.readline().rstrip()
    i = s.find('A')
    j = len(s) - s[::-1].find('Z') - 1
    print(j - i + 1)


if __name__ == "__main__":
    main()

Solution (Python):
S = str(input())
a_ind = 99999999
z_ind = 0
for i in range(len(S)):
  if S[i] == 'A':
    a_ind = min(i, a_ind)
  elif S[i] == 'Z':
    z_ind = max(i, z_ind)
print(z_ind - a_ind + 1)

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

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

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

Solution (Python):


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

if __name__ == '__main__':
    s = input()

    solve(s)

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

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

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

Solution (Python):
s = input()
 
aind = 0
for i , c in enumerate(s):
  if c == "A":
    aind =  i
    break
zind = 0
for i,c in enumerate(s):
  if c == "Z":
    zind = i
    
print(zind-aind + 1)

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

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

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

Solution (Python):
s = input()
start = 0
end = 0
flag1 = True
flag2 = True
for i in range(len(s)):
    if s[i] == "A" and flag1 == True:
        start = i
        flag1 = False
    elif s[i] == "Z":
        end = i
slNnm = (end + 1) - start
print(slNnm)

Solution (Python):
s = input()
num_A = -1
num_Z = -1
for ind,i in enumerate(s):
  if(num_A == -1 and i == 'A'):
    num_A = ind
  if(i == 'Z'):
    num_Z = ind
print(num_Z - num_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()

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

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

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

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

Solution (Python):
s = list(input())
le = len(s)
l = [x for x in range(le) if s[x] == 'A']
r = [x for x in range(le) if s[x] == 'Z']
l = min(l)
r = max(r)
print(r-l+1)

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

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

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

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

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

Solution (Python):
word = input()
start = []
end = []
for idx, w in enumerate(word):
  if w == 'A':
    start.append(idx)
  elif w == 'Z':
    end.append(idx)
  else:
    continue
print(len(word[start[0]:end[-1]+1]))

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

Solution (Python):
s = input()

ans = ''
idx = -1
for i, c in enumerate(s):
    if c == 'A' and idx == -1:
        idx = i
        break
for i, c in enumerate(reversed(s)):
    if c == 'Z':
        ans = s[idx:len(s)-i]
        break
print(len(ans))

Solution (Python):
s = input()

ans = ''
idx = -1
for i, c in enumerate(s):
    if c == 'A' and idx == -1:
        idx = i
    if c == 'Z':
        ans = s[idx:i+1]
print(len(ans))

Solution (Python):
import re

s = input()
start, end = re.search(r'A(.*)Z', s).span()
print(end - start)

Solution (Python):

s = list(input())
i = 0
while s[i] != "A":
    i += 1
j = 1
while s[-j] != "Z":
    j += 1
print(len(s) - i - j + 1)

Solution (Python):

s = list(input())
i = 0
while s[i] != "A":
    i += 1
j = 1
while s[-j] != "Z":
    j += 1
print(len(s) - i - j + 1)

Solution (Python):
S = list(str(input()))
indexes = [i for i, x in enumerate(S) if x == "Z"]
for i in range(len(S)):
    if S[i] == "A":
        tmp = S.index(S[i])
        break
ans = S[tmp:max(indexes) + 1]
print(len(ans))

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

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

Solution (Python):
s = input()

sub = 0

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

print(sub)

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

Solution (Python):
S = input()
min_ = 0
max_ = 0
flag_min = True
for i in range(len(S)):
  if flag_min:
    if S[i] == "A":
      min_ = i
      flag_min = False
  else:
    if S[i] == "Z":
      max_ = i
      
print(max_ - min_ + 1)

Solution (Python):


s = str(input())
a = [i for i, x in enumerate(s) if x == 'A'][0]
z = [i for i, x in enumerate(s) if x == 'Z'][-1]
print(z-a+1)

Solution (Python):
s = input()

begin = 0
for i in range(len(s)):
    if s[i] == "A":
        begin = i
        break
end = 0
for i in reversed(range(len(s))):
    if s[i] == "Z":
        end = i
        break

print(end - begin + 1)

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

begin = 0
for i in range(len(s)):
    if s[i] == "A":
        begin = i
        break
end = 0
for i in reversed(range(len(s))):
    if s[i] == "Z":
        end = i
        break

print(end - begin + 1)

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

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

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

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

Solution (Python):
def main():
	S = input()
	head = 0
	tail = len(S)-1
	for i, c in enumerate(S):
		if c == "A":
			head = i
			break

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


if __name__ == '__main__':
	main()

Solution (Python):


def read_input():
    s = input().strip()
    return s


def find_from_head(s, c):
    for i, sub in enumerate(s):
        if c == sub:
            return i

def find_from_tail(s, c):
    total = len(s) - 1

    for i, sub in enumerate(s[::-1]):
        if c == sub:
            return total - i

def submit():
    s = read_input()

    ai = find_from_head(s, 'A')
    zi = find_from_tail(s, 'Z')

    print(zi - ai + 1)

if __name__ == '__main__':
    submit()

Solution (Python):
s = input()
A_idx = s.find("A")
Z_idx = s.rfind(("Z"))

print(Z_idx-A_idx+1)

Solution (Python):

s=input()


a=z=-1

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


print(z-a+1)

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