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()
print(  abs( min([ k for k,v in enumerate(S) if v == "A" ])  - max([ k for k,v in enumerate(S) if v == "Z" ]) ) +1 )

Solution (Python):
s = list(input())
a = int(s.index("A"))
del s[:a]

list_z = [i for i, x in enumerate(s) if x =="Z"]
z = max(list_z)
del s[len(s):z:-1]
print(len(s))

Solution (Python):
S = input()

def findPos(s,char):
  l = []
  for i in range(len(s)):
    if s[i] == char:
      l.append(i)
  return l

A_pos = findPos(S,"A")
Z_pos = findPos(S,"Z")
print(max(Z_pos)-min(A_pos)+1)

Solution (Python):
s=input()
i=s.find('A')
j=s.rfind('Z')

print(abs(i-j)+1)

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

Solution (Python):

s = list(input())
sa = s.index("A")
m = [i for i, x in enumerate(s) if x == 'Z']

mz = int(m[-1])+1

p = (s[sa:mz])
print(len(p))

Solution (Python):
import math
from collections import deque
from collections import defaultdict
import itertools as it


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

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

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

		if x==y:
			return

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

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

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

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

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

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

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

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	
	ans = data[:]
	return ans

s = readChar()

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

print(b-a)

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

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

print(y-x+1)

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

Solution (Python):
s= list(input())
Ai=[n for n, v in enumerate(s) if v=="A"]
Zi=[n for n, v in enumerate(s) if v=="Z"]

print(max(Zi)-min(Ai)+1)

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

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

Solution (Python):
s = input()

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

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

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

Solution (Python):

def AtoZ(s) : 
  for i in range(len(s)) : 
    if s[i] =='A' : 
      addr_a = i
      break
  for j in range(len(s)) : 
    if s[len(s) - j - 1] == 'Z' : 
      addr_z  = len(s) - j - 1
      break
      
  return addr_z - addr_a + 1

s = input()

print(AtoZ(s))

Solution (Python):
s = input()
t,e = 0,0
for i in range(len(s)):
    if s[i] =='A':
        t = i
        break

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

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

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

Solution (Python):

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

Solution (Python):

import re
s = str(input())
S = (re.findall('A+[a-zA-z]+Z', s))
ss = S[0]
print(len(ss))

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 = s.rindex('Z')
print(z - a + 1)

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

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

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

Solution (Python):
import re

s=input()
a=re.findall('A.*Z', s)
print(len(*a))

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

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

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

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

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

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

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

Solution (Python):
s = input()

idx_a = 200000
idx_z = 0
for i in range(len(s)):
	if s[i] == "A":
		idx_a = min(idx_a,i)
		
	if s[i] == "Z":
		idx_z = max(idx_z,i)
		

print(len(s[idx_a:idx_z])+1)

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

for n,s in enumerate(S):
    if s == 'A':
        A_num = n + 1
        break
for n,s in enumerate(S_reverce):
    if s == 'Z':
        Z_num = len(S) - n
        break
        
ans = Z_num - A_num + 1
print(ans)

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

Solution (Python):
s = input()

st = 0
ed = 0
sl = len(s)
for i in range(sl):
    if s[i] == "A":
        st = i
        break
for i in reversed(range(sl)):
    if s[i] == "Z":
        ed = i
        break
print(sl - st - (sl-ed) + 1)

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

print(max(z) - min(a) + 1)

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

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':
    z = i
    break
print(z - a + 1)

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

Solution (Python):

s = input()
A = s.index("A")
Z = s[::-1].index("Z")
print(max(0,len(s)-1-Z-A+1))

Solution (Python):
import re
s = input()
r = re.compile(r"A[A-Z]*Z")
t = re.findall(r,s)
u = map(len, t)
print(max(u))

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

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

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

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()
Aid = 0
Zid = 0

for i in range(len(s)):
  if s[i] == "Z":
    Zid = i
for i in range(len(s)):
  if s[len(s)-i-1] == "A":
    Aid = len(s)-i-1

print(Zid - Aid +1)

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

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

for i in range(N)[::-1]:
    if s[i] == 'Z':
        rt = i
        break

print(rt - lt + 1)

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()

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

Solution (Python):

s = input()
m = -1
for i in range(len(s)):
    if s[i] == 'A' and m == -1:
        m = i
    elif s[i] == 'Z' and m != -1:
        n = i - m + 1
print(n)

Solution (Python):
s = input()

start = -1
end = -1
for index,i in enumerate(s):
  if i == "A":
    start = index
    break
for index,i in enumerate(list(reversed(s))):
  if i == "Z":
    end = len(s) - index
    break
if end == -1 or start == -1:
  print(1)
else:
  print(end -start)

Solution (Python):
s = list(input())
start = s.index('A')
s.reverse()
end = len(s) - s.index('Z')

print(end - start)

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

l = 0
r = 0

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

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

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

Solution (Python):
import re


print(len(re.search(r"A.*Z", input()).group()))

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

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

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

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

Solution (Python):
S = input()
k = 0
st = 2000000
gl = 0
for i in range(len(S)):
  if S[i] == "A":
    if st > k:
      st = k
  k += 1
  if S[i] == "Z":
    if gl < k:
      gl = k
print(gl - st)

Solution (Python):

import sys
input = sys.stdin.readline









S = input().rstrip()
 
ai = S.find("A")
zi = S.rfind("Z")
 
print(zi-ai+1)

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

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

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

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
 
 


def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
 
 

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

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

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

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

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

 
 
 

def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
 
    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P
 

def permutation_with_duplicates(L):
 
    if L == []:
        return [[]]
 
    else:
        ret = []
 
        
        S = sorted(set(L))
 
        for i in S:
 
            data = L[:]
            data.remove(i)
 
            for j in permutation_with_duplicates(data):
                ret.append([i] + j)
 
        return ret
 
 
s= input()
f=s.index("A")
l=len(s)-1-s[::-1].index("Z")
print(l-f+1)

Solution (Python):
s = input()
l = len(s)
a = 0
f = 0
z = 0

for i in range(l):
    if s[i] == "A":
        if f == 0:
            a = i
            f = 1
        else:
            pass
    elif s[i] == "Z":
        z = i
    else:
        pass

print(z-a+1)

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

Solution (Python):
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue



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

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

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


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

    S = iss()
    A, Z = MAX, 0

    for i in range(len(S)):
        if S[i] == 'A':
            A = min(A, i)
        elif S[i] == 'Z':
            Z = max(Z, i)
    print(Z - A + 1)


if __name__ == '__main__':
    main()

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

if r_s.index("Z")==0:
    print(len(s[s.index("A"):]))
else:
    print(len(s[s.index("A"):-r_s.index("Z")]))

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()

for i, c in enumerate(s):
    if c == 'A':
        a_index = i
        break

for i, c in enumerate(s[::-1]):
    if c == 'Z':
        z_index = i
        break
print(len(s[a_index:len(s)-z_index]))

Solution (Python):
s = input()
i = 0
j = len(s) - 1
t1 = []
t2 = []

while True:
  
  if(s[i] == "A"):
    t1.append(i)
    
  if(s[j] == "Z"):
    t2.append(j)
  if(len(t1) != 0 and len(t2) != 0):
    break
  i += 1
  j -= 1
  
print(t2[0]-t1[0] +1)

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

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

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

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



print(t)

Solution (Python):
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()

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

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

print(e-h+1)

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

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()

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

print(b-a+1)

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

Solution (Python):
from math import *

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

def cins(): 
    return input.split()

def cino(test=False): 
    if not test:
        return int(input())
    else: 
        return input()

def cina(): 
  return list(map(int,input().split()))

def ssplit(): 
    return list(input().split())

def printlist(l): 
    for i in l:
        print(i,end=" ")

def main():
    s = input()
    s = list(s)
    init = -1
    end = len(s)
    for i in range(len(s)):
        if s[i]=='A' and init==-1:
            init = i
        if s[i]=='Z':
            end = i
    print(end-init+1)


if __name__ == '__main__':
    main()

Solution (Python):
import re

s = input()
x = ""
for i,k in enumerate(s):
    if k == "A":
        x = s[i:][::-1]
        for j,t in enumerate(x):
            if t == "Z":
                x = x[j:]
                break
        break
                
print(len(x))

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

Solution (Python):
s = input()

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

for i in range(len(s)):
    if s[i] == "A":
        a = min(a, i)
    if s[i] == "Z":
        z = max(z, i)

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

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

print(len(s)-s.find("A")-t.find("Z"))

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

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    n = len(s)
    start, end = 0, 0
    for i, char in enumerate(s):
        if char == '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(len(s)-s[::-1].index("Z")-s.index("A"))

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

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

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

Solution (Python):
s = input()
print(s.rindex('Z') - s.index('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()

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

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

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

start = -1
end = -1
for i, s in enumerate(S):
    if s == "A" and start == -1:
        start = i
    if s == "Z" and start != -1:
        end = i

if start != -1 and end != -1:
    print(end - start + 1)

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

def Main(S):
    ans = 0
    candidate = 0
    flag = False
    for c in S:
        if c == 'A':
            flag = True
        if flag:
            candidate += 1
            if c == 'Z':
                ans = candidate
    return ans
            
    
res = Main(S)
print(res)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




S = inputS()
N = len(S)
for i in range(N):
  if S[i] == "A":
    a = i
    break
for i in range(N)[::-1]:
  if S[i] == "Z":
    z = i
    break

print(z-a+1)

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

Solution (Python):
s = input()

for ind, i in enumerate(s):
    if i == 'A':
        num1 = ind
        break

for ind, i in enumerate(s):
    if i == 'Z':
        num2 = ind

print(num2 - num1 + 1)

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

abc053_b()

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

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

Solution (Python):
s = input()

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

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

ans = end - start + 1
print(ans)

Solution (Python):
s = input()

def solve(s):
    maximum = 0
    a = 0
    counting = False
    for i in s:
        if i == "A":
            counting = True
        
        if counting == True:
            a += 1
        
        if i == "Z" and counting == True:
            maximum = a
    
    print(maximum)
        

solve(s)

Solution (Python):

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

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

Solution (Python):
s = input()
a = float('inf')
z = 0
for i, c in enumerate(s):
    if c == 'A':
        a = min(i, a)
    elif c == 'Z':
        z = max(i, z)
print(z - a + 1)

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

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

print(z-a+1)

Solution (Python):
s = input()
a = []
z = []
for index,ss in enumerate(s):
	if ss == "A":
		a.append(index)
	elif ss == "Z":
		z.append(index)
print((z[-1]-a[0])+1)

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

Solution (Python):
s = input()
start = -float('inf')
best_length = -float('inf')
for i,w in enumerate(s):
  if w=='A' and start < 0:
    start = i
  elif w=='Z' and start >= 0:
    length = i - start + 1
    if length > best_length:
      best_length = length
print(best_length if best_length > 0 else 0)

Solution (Python):
l=list(input())
a_l =[i for i,x in enumerate(l) if x=='A']
z_l =[i for i,x in enumerate(l) if x=='Z']
if z_l[-1]-a_l[0] > 0:
    print(z_l[-1]-a_l[0]+1)

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

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

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

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

Solution (Python):
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
a=input()
A=0
Z=0
Adone=False
for i in range(len(a)):
    if(a[i]=='A' and not Adone):
        A=i 
        Adone=True
    elif(a[i]=='Z'):
        Z=i 
ans=Z-A+1
print(ans)

Solution (Python):
s = input()
top, last = 0, 0
for i, c in enumerate(s):
    if c == 'A':
        top = i
        break

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