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

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

Solution (Python):

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

Solution (Python):
s = input()
flg_A, flg_Z = 1, 1
N = len(s)
for i in range(N):
    if flg_A:
        if s[i] == 'A':
            idx_A = i
            flg_A = 0
    if flg_Z:
        if s[N-1-i] == 'Z':
            idx_Z = N-1-i
            flg_Z = 0

print(idx_Z - idx_A + 1)

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

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

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


ans = goal - start + 1

print(ans)

Solution (Python):

s=list(str(input()))

s1 = [i  for (i,x) in enumerate(s) if x =='A' ]
s2 = [i  for (i,x) in enumerate(s) if x =='Z' ]

x=min(s1)
y=max(s2)
print(y-x+1)

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

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

Solution (Python):
s = input()
a = []
z = []

for i in range(len(s)):
    if s[i] == 'A':
        a.append(i)
    if s[i] == 'Z':
        z.append(i)
A= min(a)
Z= max(z)

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

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

res = re.findall("A.*Z", s)
print(len(res[-1]))

Solution (Python):
s=input()

a=s.find("A")

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

Solution (Python):
s=input()

a=s.find('A')

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

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

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

z = 0

a = s.find("A")

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

print(z - a + 1)

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

a = 199999
z = 0

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

    elif s[i]  == "Z":
        z = max(z,i)

print(z - a + 1)

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

Solution (Python):
import re
s = input()
a = re.search(r'A.*Z',s)

print(a.end()-a.start())

Solution (Python):
s = input()
l = r = 0
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
        break
print(r - l)

Solution (Python):
s=input()
l=len(s)
a=0
b=0
for x in range(l):
    if s[x]=='A':
        a=x
        break

for x in range(l):
    if s[l-x-1]=='Z':
        b=l-x-1
        break
c=b-a+1
print(c)

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

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

Solution (Python):

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

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

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

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

Solution (Python):
s = input()
a_ind = []
z_ind = []
for i, t in enumerate(s):
    if t == "A":
        a_ind.append(i)
    if t == "Z":
        z_ind.append(i)
print(max(z_ind) - min(a_ind) + 1)

Solution (Python):




def main():
    s = raw_input()
    st = s.find('A')
    en = s[::-1].find('Z')
    print((len(s) - en) -st)

    

if __name__ == "__main__":
    main()

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    init_a = S.index('A')
    last_z = S[::-1].index('Z')

    N = len(S)

    return N - init_a - last_z


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

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()
l = len(s)

a = s.index("A")
z = s[::-1].index("Z")

print(l - a - z)

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

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

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

Solution (Python):
s = input()

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

Solution (Python):

slis=list(str(input()))

A=[i for i, x in enumerate(slis) if x == 'A']
Z=[i for i, x in enumerate(slis) if x == 'Z']

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

Solution (Python):
string = input()
string_list = [s for s in string]
 
def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)
  return index
 
index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)
 
print(index_of_z[-1] - index_of_a[0]+1)

Solution (Python):
S = input()

index_A = []
index_Z = []
for i in range(len(S)):
    if S[i] == "A" and len(index_A) == 0:
        index_A.append(i+1)
    if S[i] == "Z":
        index_Z.append(i+1)
            
print(max(index_Z) - index_A[0] + 1)

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

Solution (Python):
s=input()

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

print(z[-1]-a[0]+1)

Solution (Python):
S = input()
head = 0
end = 0

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

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

print(end - head)

Solution (Python):
S = input()
head = 0
end = 0

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

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

print(end - head)

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

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

Solution (Python):
s = input()

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

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

print(z_index - a_index + 1)

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

Solution (Python):
s = input()

left = 0
right = 0
flag = True
for i in range(0,len(s)):
    if s[i] == "A" and flag:
        left = i
        flag = False
    if s[i] == "Z":
        right = i

print(right  - left + 1)

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    

    s = list(_ for _ in input())
    max_s = 0
    from_i = 0
    to_i = 0
    for i in range(len(s)):
        if s[i] == 'A':
            from_i = i
            break
    s = s[::-1]
    for i in range(len(s)):
        if s[i] == 'Z':
            to_i = i
            break

    print((len(s)-to_i) - from_i)
    
if __name__ == '__main__':
    main()

Solution (Python):
s=input()

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

Solution (Python):
s = str(input())
count = 1
for i in s:
    if i == "A":
        A_index = count
        break
    count += 1
    
count = 1
for i in list(reversed(s)):
    if i == "Z":
        Z_index = count
        break
    count += 1
    
print(len(s)-A_index-Z_index+2)

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

Solution (Python):
S = 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":
        last = i
        break
print(last-start+1)

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

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

Solution (Python):
s = input()
index = []
for i, c in enumerate(s):
    if c == "A":
        index.append(i)
        break

for i, c in enumerate(reversed(s)):
    if c == "Z":
        index.append(len(s)-i)
        break

count = len(s[index[0]:index[1]])
print(count)

Solution (Python):
s = input()
pos = 0
while s[pos] != 'A':
    pos += 1

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

print(end - pos + 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=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()
ans = s.rfind("Z") - s.find("A") + 1
print(ans)

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


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

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

Solution (Python):
S = list(input())
A_index = S.index("A")
S_gyaku = [i for i in S[::-1]]
Z_index = len(S) - S_gyaku.index("Z")
print(Z_index-A_index)

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

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

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

print(len(s[i:n-j]))

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


if __name__ == "__main__":
    s = input()
    ans = a2z_string(s)
    print(ans)

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

Solution (Python):
N=list(input())
N_num=len(N)
max_num=0
min_num=0


for i in range(N_num):
        if N[i] == "A":
                min_num=i
                break

N.reverse()
for i in range(N_num):
        if N[i] == "Z":
                max_num=i
                break

print(N_num-max_num-min_num)

Solution (Python):
N=input()

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

Solution (Python):
s = input().rstrip()
A,Z = -1, -1
length = len(s) - 1

for i in range(length):
    if A == -1:
        if s[i] == "A":
            if A == -1:
                A = i
                A_flag = True
    if Z == -1:
        if s[length-i] == "Z":
            if Z == -1:
                Z = length-i
                Z_flag = True
    if A != -1 and Z != -1:
        break

print(Z-A+1)

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

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

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

b =0
for i in a:
    if i == "A":
        del a[0:b]
        break
    else:
      b += 1

c = list(reversed(a))

x = 0
for n in c:
    if n == "Z":
        del c[0:x]
        break
    else:
        x += 1
        
print(len(c))

Solution (Python):
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_SM(n):
	return [tuple(INSTR_S()) for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

S = INSTR()
print(S.rfind("Z") - S.find("A") + 1)

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

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
x = I()
if x < 1200:
    print("ABC")
else:
    print("ARC")
"""

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

"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""


"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
"""

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

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

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

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

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

Solution (Python):

s = input()

before = [i for i, x in enumerate(s) if x == 'A']
back = [i for i, x in enumerate(s) if x == 'Z']
print(max(back) - min(before) + 1)

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

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

Solution (Python):
s = input()
a = z = -1
for i, v in enumerate(s):
    if a == -1:
        if v == 'A':
            a = i
    if z == -1:
        if s[len(s) - i -1] == 'Z':
            z = len(s) - i
            
    if a >= 0 and z >= 0:
        print(z - a)
        exit()

Solution (Python):
x=list(input())
a=-100
z=0
for i in range(len(x)):
  if x[i]=="A" and a==-100:
    a=i
  elif x[i]=="Z":
    z=i
print(z-a+1)

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

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

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

print(len(S)-end-begin)

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

Solution (Python):


x = input()

a = 0
z = 0

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

for i in range(len(x)):
    if x[-(i+1)] == "Z":
        z = len(x) - i
        break

print(len(x[a:z]))

Solution (Python):
s = input()
l = s.find('A')
r = s.rfind('Z')
print(r-l+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()
st = s.index("A")
en = s[::-1].index("Z") 
print(len(s)-en-st)

Solution (Python):
s=list(input())
x=s.index('A')
t=list(reversed(s))
y=t.index('Z')
print(len(s)-x-y)

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

val = 0
memo = []
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()

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

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

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


if __name__ == "__main__":
    main()

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

rev_s = list(reversed(s))

n = len(s)

a = s.index('A')
z = n - rev_s.index('Z')

print(z-a)

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

Solution (Python):
Ss = [i for i in input()]
Aa = []
Zz= []
for s in range(len(Ss)):
    if Ss[s]=="A":
        Aa.append(s+1)
    if Ss[s]=="Z":
        Zz.append(s+1)
print(Zz[-1]-Aa[0]+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)
A=min(a)
Z=max(z)
print(Z-A+1)

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

Solution (Python):
S = input()
N = len(S)
for i in range(N):
    if S[i] == 'A':
        a_index = i
        break
S=S[::-1]
for i in range(N):
    if S[i] == 'Z':
        z_index = i
        break

print(N - z_index - a_index)

Solution (Python):
S = input()
N = len(S)
for i, s in enumerate(S):
    if s == 'A':
        a_index = i
        break
for i, s in enumerate(S[::-1]):
    if s == 'Z':
        z_index = i
        break

print(N - z_index - a_index)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import re
m = re.search(r'A.*Z', input())
print(m.end() - m.start())

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

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

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

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

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

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

print(y-x+1)

Solution (Python):
s = input()

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

print(ans)

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

Solution (Python):

"""
Created on Fri Mar 15 09:40:47 2019

@author: 17664
"""

s = input()

idxA = s.index('A')

searchZ = s[idxA:]

idxZ = 0

for i in range(len(searchZ)):
    if searchZ[i] == 'Z':
        idxZ = i

print(len(searchZ[:idxZ+1]))

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

Solution (Python):

s = input()


left_A  = -1  
right_Z = -1  

for i in range(len(s)):
  
  if left_A < 0 and s[i] == "A":
    left_A = i
  if s[i] == "Z":
    right_Z = i


print(right_Z - left_A + 1)

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

a = s.index('A')
b = len(s) - list(reversed(s)).index('Z')

print(b - a)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)

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

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

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

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

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

Solution (Python):
s = input()
res = 0
index_a = -1
index_z = -1
for i in range(len(s)):
    if s[i] == 'A':
        index_a = i
        for j in range(len(s[i:])):
            if s[i+j] == 'Z':
                index_z = i+j
        break


print(index_z - index_a + 1)

Solution (Python):
s = input()

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

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

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

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

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

Solution (Python):
import re
string = input()
results = re.findall('A.*Z', string)
print(max(list(map(len, results))))

Solution (Python):
import re
string = input()
results = re.findall('A.*Z', string)
results_len = list(map(len, results))
print(max(results_len))

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s






a = input()                                  






left  = 0
for left in range(len(a)):
    if a[left] == "A":
        break
for right in range(len(a)-1,-1,-1):
    if a[right] =="Z":
        break
print(right-left+1)

Solution (Python):
s = str(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_list = list(input())
a_num = 0
z_num = 0
for i,a in enumerate(s_list):
    if a == 'A':
        a_num = i
        break
rs_list = reversed(s_list)
for j,z in enumerate(rs_list):
    if z == 'Z':
        z_num = j
        break
if z_num == 0:
    print(len(s_list[a_num:]))
else:
    print(len(s_list[a_num:-z_num]))

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(len(s[s.find("A"):s.rfind("Z") + 1]))

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

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

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

print(z-a+1)

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

index1 = s.index('A')
s.reverse()
index2 = s.index('Z')
index2 = (len(s)-1) - index2
print(index2 - index1 + 1)

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

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

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

for i in range(len_s)[::-1]:
  if s[i]=="Z":
    last = i
    break
print(last-first+1)

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

Solution (Python):

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

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

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

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

max = 0
i = 0
while i < len(s):
    if s[i] == 'A':
        b = i
        i += 1
        while i < len(s):
            if s[i] == 'Z':
                e = i
                max = e - b +1
                i += 1
            else:
                i += 1
    else:
        i += 1
print(max)

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

Solution (Python):

"""
Created on Wed Feb 27 01:23:46 2019

@author: yuta
"""

def atoz(s):
    index_a = s.find('A')
    index_z = len(s) - 1 - s[::-1].find('Z')
    x = index_z - index_a + 1
    if x >= 2:
        print(x)

atoz(input())

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

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

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

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

Solution (Python):
s = list(input())
x = 0
y = 0
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(j-i+1)

Solution (Python):
"""AtCoder"""

s = input()

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

Solution (Python):
s = list(input())
if len(s) == 1:
    print(0)
    exit()
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
print(end - start + 1)

Solution (Python):
S = input()

a = S.find('A')
cnt = 1
for s in S[::-1]:
  cnt -= 1
  if(s == 'Z'):
    break
z = len(S) + cnt
print(len(S[a:z]))

Solution (Python):

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



for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)


r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	
	if(i!="Z"):
		s_l.pop()

	else:
		break


str_s_l=''.join(s_l)

print(len(str_s_l))

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

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

Z_lst = []
for i in range(0, len(s)):
    if s[i] == "Z":
        Z_lst.append(i)
        
A = min(A_lst)
Z = max(Z_lst)



ans = 0

for i in range(A, Z + 1):
    ans += 1
    
print(ans)

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

Solution (Python):
s=input()
ans=0
for i in range(len(s)):
    if s[i] == 'A':
        for j in range(len(s)-1,0,-1):
            if s[j] == 'Z':
                if ans < abs(i-j):
                    ans = abs(i-j)
                break

print(ans+1)

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

Solution (Python):
s=input()
a=0
z=0
i=0
j=len(s)-1
while a==0 :
    if s[i]=="A":
        a=1
    else:
        i+=1
while z==0:
    if s[j]=="Z":
        z=1
    else:
        j-=1
print(j-i+1)

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

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

Solution (Python):
s = raw_input()

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

Solution (Python):
s = input()

num = len(s)

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

for j in range(0, num):
    if s[j] == 'A':
        break

print(i - j + 1)

Solution (Python):
def fun():
     print('ac')
     print('AC')
     print('ACAC')
     print('ac')
     print('aacc')
ls=input()
k=0
s=0
kai=len(ls)
for i in range(len(ls)):
     if ls[i]=='A':
          if kai>i:
               kai=i
     if ls[i]=='Z':
          if i>s:
               s=i
print(s-kai+1)

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