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



Sample input:
QWERTYASDFZXCV


Sample output:
5

Submission status: Accepted

Solution code:
s=list(input())

a=s.index("A")

s.reverse()

b=s.index("Z")

s.reverse()

if b==0:
    T=s[a:-1]
    print(len(T)+1)
else:
    T=s[a:-b]
    print(len(T))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    s = input()

    idx_min = s.index("A")
    idx_max = s.rindex("Z")
    print(idx_max - idx_min + 1)

if __name__ == "__main__": main()

Submission status: Accepted

Solution code:
s = str(input())

index1 = s.index("A")
temp = s[::-1].index("Z")
index2 = len(s) - temp

print(index2 - index1)

Submission status: Accepted

Solution code:
s = input()
a, z, ans = (0, 0, 0)
 
a = s.find("A")
z = s.rfind("Z")
ans = z - a + 1
print(ans)

Submission status: Accepted

Solution code:
s = list(raw_input())
flag1 = True
flag2 = True
for i in range(len(s)):
	if s[i] == 'A' and flag1:
		startIndex = i
		flag1 = False
	if s[len(s) - i - 1] == 'Z' and flag2:
		endIndex = len(s) - i
		flag2 = False
	if not flag1 and not flag2:
		break

print endIndex - startIndex

Submission status: Accepted

Solution code:
s=input().strip()
rev=s[::-1]
n=len(s)
#print(n)
print((n-rev.find('Z')) - (s.find('A')))

Submission status: Accepted

Solution code:
S = input()

s_ind = 0
e_ind = 0


for i, s in enumerate(S):
    if s == "A":
        s_ind = i
        break
        
for i in range(len(S)):
    if S[-(i+1)] == "Z":
        e_ind = len(S)-(i+1)
        break
        
print(e_ind - s_ind + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

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

Submission status: Accepted

Solution code:
from collections import defaultdict


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)
sp = 0
gp = l - 1

while sp < l:
  if s[sp] == 'A':
    break
  sp += 1
  
while gp >= -1:
  if s[gp] == 'Z':
    break
  gp -= 1

if gp > sp:
  print(gp - sp + 1)
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = []
s = input()
min_a = -1
max_z = 0
for i in range(len(s)):
  if s[i]=='A' and min_a==-1:
    min_a = i
  elif s[i]=='Z':
    max_z = i
 
print(max_z-min_a+1)

Submission status: Accepted

Solution code:
s = input()

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

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

print(z-a+1)

Submission status: Accepted

Solution code:
print(len(max(__import__("re").findall('A.*Z', input()))))

Submission status: Accepted

Solution code:
s = raw_input()
start = s.index('A')
end = s.rindex('Z')
print end - start + 1

Submission status: Accepted

Solution code:
S = input()
i = 0
j = -1

while True:
    if S[i] == "A":
        A = i
        break
    i += 1

while True:
    if S[j] == "Z":
        Z = len(S) + j
        break
    j -= 1
    
print(Z - A + 1)

Submission status: Accepted

Solution code:
s = input()

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

print(end+1-start)

Submission status: Accepted

Solution code:
S = input()
a = -1
z = -1
for i in range(len(S)):
    if S[i] == 'Z':
        z = i
    if S[-i - 1] == 'A':
        a = len(S) - i - 1
print(z - a + 1)

Submission status: Accepted

Solution code:
import re; print len(re.compile("A.*Z").search(raw_input()).group(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()
left = min([i for i in range(len(s)) if s[i] == 'A'])
right = max([i for i in range(len(s)) if s[i] == 'Z'])
print (right - left + 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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]:
    if(S[i] == "Z"):
      b = i
      break

print(b - a + 1)

Submission status: Accepted

Solution code:
s = input()

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

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

print((b - a) + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = raw_input()
start = s.index("A")
end = s.rindex("Z")
print end - start + 1

Submission status: Accepted

Solution code:
s = list(input())

cnt = 0
on = False
result = []
for a in s:
    if a is 'A':
        on = True
    if on:
        cnt += 1
    if a is 'Z':
        result.append(cnt)

print(max(result))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    s = input()
    i1 = s.find('A')
    i2 = s.rfind('Z')
    print(i2-i1+1)

Submission status: Accepted

Solution code:
x = list(input())
a = []
z = []

for i in range(len(x)):
    if x[i] == 'A':
        a.append(i)
    elif x[i] == 'Z':
        z.append(i)
    else:
        pass

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

Submission status: Accepted

Solution code:
s = list(input())
cnt = 0
i = 0
j = len(s)-1
for t in range(len(s)):
    if s[t] == "A":
        break
    i += 1
for t in range(len(s)):
    if s[j] == "Z":
        break
    j -= 1
print(j-i+1)

Submission status: Accepted

Solution code:
s=raw_input()
l=len(s)
a=None
b=None
a=s.find('A')
s=s[::-1]
b=s.find('Z')
print l-b-a

Submission status: Accepted

Solution code:
def main():
  s = input()
  si , ei = 0, len(s) - 1
  while True:
    if s[si] == 'A':
      break
    si += 1
  while True:
    if s[ei] == 'Z':
      break
    ei -= 1
  print(ei - si + 1)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    s = S()
    a = s.index('A')
    z = s.rindex('Z')
    return z-a+1

print(main())

Submission status: Accepted

Solution code:
s = input()


def main(s):
    a_index = 200000 
    z_index = -1
    i = 0

    for c in s:
        if c == 'A':
            a_index = min(a_index, i)
        elif c == 'Z':
            z_index = max(z_index, i)
        i += 1

    return (z_index - a_index) + 1


print(main(s))

Submission status: Accepted

Solution code:
def main():
    s = input()
    si, ei = 0, len(s) - 1
    while True:
        if s[si] == 'A':
            break
        si += 1
    while True:
        if s[ei] == 'Z':
            break
        ei -= 1
    print(ei - si + 1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
if __name__ == '__main__':
  s = str(input())
  L = len(s)
  beg = -1
  end = -1
  for i in range(0,L):
    if s[i]=='A' and beg==-1:
      beg = i
    elif s[i]=='Z':
      end = i
  print(end-beg+1)

Submission status: Accepted

Solution code:
import sys

def solve():
    s = input()
    l = s.find('A')
    r = s.rfind('Z')

    print(r - l + 1)
    
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

words=input().rstrip()

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

print(z-a+1)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:








def sol(strs):

	ptrA=0;
	ptrZ=len(strs)

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

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

	return (ptrZ - ptrA+1)





inD =raw_input()

inD = str(inD)

print sol(inD)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

s = input()

x = s.find('A')
y = 0
for i in range(len(s)):
    if s[i] == 'Z':
        y = i + 1

print(y-x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

f = False
c = 0
max_c = 0

for k, i in enumerate(S):
    if i == 'A' and f == False:
        f = True
        c += 1
    elif i == 'Z' and f == True:
        c += 1
        max_c = max(c, max_c)
        if S[k] != 'Z':
            f = False
    elif f == True:
        c += 1

print(max_c)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    [s] = input().split()
    a_pos = s.find("A")
    z_pos = (len(s) - 1) - s[::-1].find("Z")

    print(z_pos - a_pos + 1)

Submission status: Accepted

Solution code:
import sys
input_lines1 = sys.stdin.readlines()
for line in input_lines1:
    strBuf = line.replace('\n', '').split(' ')
    maxValue = 0
    index = 0
    start = -1
    end = 0
    for idx in range(len(strBuf[0])) :
        if start == -1 :
            if strBuf[0][idx:idx+1] == 'A' :
                start = idx
            else:
                continue

        if strBuf[0][idx:idx+1] == 'Z' :
            if not 'Z' in strBuf[0][idx+1:] :
                end = idx
                break
print end - start + 1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():
    str=input()
    a,b=0,0
    l=len(str)
    
    for i in range(l):
        if(str[i]=='A'):
            a=i
            break
    for i in reversed(range(l)):
        if(str[i]=='Z'):
            b=i
            break
    print(b-a+1)
        


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
i = 0
for char in S:
    if char == "A":
        first = i
        break
    else:
        i += 1
n = 0
for char in S[::-1]:
    if char == "Z":
        last = n
        break
    else:
        n += 1

print(len(S[i:len(S)-n]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
print(max(map(len, re.findall("A.*Z", input()))))

Submission status: Accepted

Solution code:
import re

r = re.compile(r"A.*Z")
print(max(map(len, r.findall(input()))))

Submission status: Accepted

Solution code:
s = input()
posA = s.find('A')
posZ = len(s) - s[::-1].find('Z') - 1 # s[::-1]でsを反転
print(posZ - posA + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():
    a = str(input())
    print(a.rindex('Z') - a.index('A') + 1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
string = input()

z_idx = len(string) - string[::-1].index('Z') - 1

a_idx = string.index('A')

print (z_idx - a_idx + 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

a = input()
start = a.find('A')
end = len(a) - a[::-1].find('Z')

print(end - start)

Submission status: Accepted

Solution code:
s = input()
w = ""
ans = ""
f = 0
for c in s:
    if c == "A":
        f = 1
    if f == 1:
        w += c
        if c == "Z":
            ans = w
ans = len(ans)
print(ans)

Submission status: Accepted

Solution code:
s = raw_input()
aId = s.index("A")
s = s[::-1]
zId = s.index("Z")
print len(s) - aId - zId

Submission status: Accepted

Solution code:
import re

m = re.search('A.*Z', input())
print(len(m.group(0)))

Submission status: Accepted

Solution code:
s = raw_input()

counter = 0
counterA = 0
counterZ = 0

flag = False

for i in range(len(s)):
    counter += 1
    if s[i] == 'A' and not flag:
        counterA = counter
        flag = True
    if s[i] == 'Z':
        counterZ = counter
        

print counterZ-counterA+1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=raw_input()
a=S.find('A')
b=S.rfind('Z')
print(b-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=raw_input()
n=len(s)
for i in xrange(n):
    if s[i]=="A":
        idx1=i
        break    
for i in xrange(n-1,0,-1):
    if s[i]=="Z":
        idx2=i
        break
print idx2-idx1+1

Submission status: Accepted

Solution code:
#ABC053B

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

Submission status: Accepted

Solution code:
S = input()
l = S.index("A")
r = S[::-1].index("Z")
n = len(S)
print(n-l-r)

Submission status: Accepted

Solution code:
print(len(''.join(''.join(input().partition('A')[1:]).rpartition('Z')[:2])))

Submission status: Accepted

Solution code:
s = input()

a,z = 0, len(s)-1

while s[a] != 'A':
    a += 1
while s[z] != 'Z':
    z -= 1

print(z-a+1)

Submission status: Accepted

Solution code:
s = input()
start = s.index("A")
fin = s.rindex("Z")
ans = s[start:fin+1]
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()

s_long = len(s)
first_a_adress = -1
end_z_adress = -1
for var in range(0,s_long):
	if s[var] == 'A':
		first_a_adress = var
		break
				
for var in reversed(range(0,s_long)):
	if s[var] == 'Z':
		end_z_adress = var
		break
print end_z_adress - first_a_adress + 1

Submission status: Accepted

Solution code:
S = input()

i = 0
j = len(S) - 1

while 1:
    if S[i] == "A":
        break
    i += 1

while 1:
    if S[j] == "Z":
        break
    j -= 1

print(j - i + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
print(max((len(i) for i in re.findall(r"A.+Z", input()))))

Submission status: Accepted

Solution code:
import re
def Main():
  s = input()
  # r = re.findall("A.+Z",s)
  # # print(r)
  # cnt = 0
  # for i in r:
  #   cnt = max(cnt, len(i))
  ans = re.findall("A[A-Z]+Z", s)
  print(len(ans[0]))

  # print(cnt)
# QWERTYASDFZXCV

if __name__ == '__main__':
  Main()

Submission status: Accepted

Solution code:
import re
def Main():
  s = input()
  r = re.findall("A.+Z",s)
  # print(r)
  cnt = 0
  for i in r:
    cnt = max(cnt, len(i))

  print(cnt)
# QWERTYASDFZXCV

if __name__ == '__main__':
  Main()

Submission status: Accepted

Solution code:
import re
s = input()
r = re.findall(r"A.+Z", s)
ans = 0
for i in r:
    ans = max(ans, len(i))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = 1000000
r = 0
for i, c in enumerate(s):
    if c == "A":
        l = min(l, i)
    if c == "Z":
        r = i
print(r - l + 1)

Submission status: Accepted

Solution code:
s=raw_input()
print-~s.rindex("Z")-s.index("A")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力

s = raw_input()

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


print b-a+1

Submission status: Accepted

Solution code:
s = input()
n = len(s)
res = 0

for i in range(0, n):
    if s[i] == "A":
        j = i
        break
for i in range(0, n):
    if s[i] == "Z":
        k = i

res = k - j + 1
print(res)

Submission status: Accepted

Solution code:
s = input()


def get_z_idx(s):
    l = len(s) - 1
    for i in range(l, -1, -1):
        if s[i] == 'Z':
            z_idx = i
            break
    return z_idx


def main(s):
    a_idx = s.index('A')
    z_idx = get_z_idx(s)
    _s = s[a_idx:z_idx + 1]
    return len(_s)


print(main(s))

Submission status: Accepted

Solution code:
"""
一番左のaの位置と一番右のzの位置だけわかればよい
"""
s = input()
a = s.index('A')
z = len(s)-s[::-1].index('Z')
print(z-a)

Submission status: Accepted

Solution code:
import re
p = input()
m = re.findall(r"A.+Z",p)        
print(len(m[0]))

Submission status: Accepted

Solution code:
s = input()

f = -1
b = -1
i = 0
n = len(s) - 1

while f == -1:
    if s[i] == 'A':
        f = i
    i = i + 1

while b == -1:
    if s[n] == 'Z':
        b = n
    n = n - 1

print(b - f + 1)

Submission status: Accepted

Solution code:
import re

s = input()
slist = re.findall("A.*Z",s)

print(len(slist[0]))

Submission status: Accepted

Solution code:
#B
num = [i for i in raw_input()]
result = 0

a = len(num)
z = 0

for i in range(len(num)):
    if num[i] == "Z" and i>z:
        z = i
    elif num[i] == "A" and i<a:
        a = i
temp = z-a
if temp>0:
    print(temp+1)
else:
    print(0)

Submission status: Accepted

Solution code:
input_str=input()
# input_str="QWERTYASDFZXCV"
# input_str="ZABCZ"
# input_str="HASFJGHOGAKZZFEGA"
b=0
e=0
length=len(input_str)
for i, s in enumerate(input_str):
	if s=="A":
		b=i
		# print(b)
		break
for i, s in enumerate(input_str[::-1]):
	if s=="Z":
		e=length-i
		# print(e)
		break
print(e-b)

Submission status: Accepted

Solution code:
input_line = raw_input()

idx_start = 0
while input_line[idx_start] != 'A':
    idx_start += 1

idx_end = len(input_line)
while input_line[idx_end-1] != 'Z':
    idx_end -= 1

print(idx_end - idx_start)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import re
s = input()
ans = re.findall(r"A[A-Z]+Z", s)
print(len(ans[0]))

Submission status: Accepted

Solution code:
S = []
while len(S) < 1 or len(S) > 200000:
    S = raw_input()

Slist = list(S)
i=0
a = len(Slist)
z = -1
for s in Slist:
    if s == 'A':
        if a > i:
            a = i
    if s == 'Z':
        if z < i:
            z = i
    i += 1
            
if z > a:
    print z - a + 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

s = raw_input()
l = list(s)
A = l.index("A")
l.reverse()
Z = l.index("Z")
a = len(l)
print a - Z -A

Submission status: Accepted

Solution code:
s = input()
length = len(s)
#print("length:",length)
first = s.index("A")
#print("first:",first)
s_rev = s[::-1]
#print(s_rev)
end_rev = s_rev.index("Z")
#print("end_rev",end_rev)
end = (length - 1) - end_rev
#print("end",end)
print(end-first + 1)

Submission status: Accepted

Solution code:
S = input()

i = 0
for i in range(len(S)):
    s1 = S[i:i+1]
    if (s1 == 'A'):
        break

for j in range(len(S)):
    k = len(S) - j
    s2 = S[k-1:k]
    if (s2 == 'Z'):
        break

print(k-1-i+1)

Submission status: Accepted

Solution code:
s = input()

a_i = None
z_i = None
set_a = False

for i in range(len(s)):
    if (not set_a) and s[i] == 'A':
        a_i = i
        set_a = True
    if s[i] == 'Z':
        z_i = i
print(z_i - a_i + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

Aindex = s.find("A")
Zindex = s.rfind("Z")

MaxLength = Zindex - Aindex + 1

print(MaxLength)

Submission status: Accepted

Solution code:
import re
s=raw_input()
r=re.compile("A.*Z")
print max(map(lambda s:len(s),r.findall(s)))

Submission status: Accepted

Solution code:
s = input()
s = s[::-1]

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

print(max)

Submission status: Accepted

Solution code:
#coding: UTF-8
s=input()
nA=s.find('A')
nZ=s.rfind('Z')
print(nZ-nA+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(len(s)-a-z)

Submission status: Accepted

Solution code:
s = input()
acnt = 999999
zcnt = 0

for i in range(len(s)):
    if s[i] == 'A':
        acnt = min(acnt, i)
    elif s[i] == 'Z':
        zcnt = max(zcnt, i)
    else:
        next
print(zcnt - acnt + 1)

Submission status: Accepted

Solution code:
s=input()
c=0
for i in range(len(s)):
  if s[i]=="A" and c==0:
     a=i
     c=1
  if s[i]=="Z":
     b=i
print(b-a+1)

Submission status: Accepted

Solution code:
s = raw_input()
memo1 = []
memo2 = 0
cnt = 0
for x in s:
    if x == "A":
        memo1.append(cnt)
    elif x == "Z":
        memo2 = cnt
    cnt += 1

print memo2 - memo1[0] + 1

Submission status: Accepted

Solution code:
s = raw_input()

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

for (i,c) in enumerate(s[::-1]):
    if c == 'Z':
        iz = i
        break

print len(s) - iz - ia

Submission status: Accepted

Solution code:
import re
s = input()
matched_list = re.findall(r'A[A-Z]*Z', s)
print(max([len(m) for m in matched_list]))

Submission status: Accepted

Solution code:
s = input()
t = list(s)
u = t[:]
t.reverse()
i, j = u.index('A'), len(s)-t.index('Z')
print(j-i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
a = S.index('A')
b = list(reversed(S)).index('Z')
print(len(S)-b-a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = raw_input()
start = 0
end = 0
for i,stri in enumerate(s):
    if stri == "A":
        start = i
        break
for i,stri in enumerate(s[::-1]):
    if stri == "Z":
        end = i
        break

print (len(s)-end)-start

Submission status: Accepted

Solution code:
s = str(input())
s = list(s)
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 = j
        break
print((len(s)-j)-i)

Submission status: Accepted

Solution code:
import sys

s = next(sys.stdin).strip()
print(s.rindex('Z') - s.index('A') + 1)

Submission status: Accepted

Solution code:
S = input()

subs = 0
l = len(S)
i = 0
while i < l:
    if S[i] != "A":
        i += 1
        continue
    else:
        for j in range(l-1, i, -1):
            if S[j] == "Z":
                subs = j - i + 1
                break
        break
print(subs)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

s = input()

i = s.find("A")
j = s.rfind("Z")
a = s[i:j+1]
# print(a)
print(len(a))

Submission status: Accepted

Solution code:
s = input()
ind_A = 0
ind_Z = 0
for i in range(len(s)):
    if (s[i] == "A"):
        ind_A = i
        break

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

print(ind_Z - ind_A + 1)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
for i in range(N):
	if S[i]=="A":
		a_n = i
		break
for i in range(N-1, -1, -1):
	if S[i]=="Z":
		z_n = i
		break
print(z_n-a_n+1)

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().strip()

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

Submission status: Accepted

Solution code:
s = input()

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

print(b-a+1)

Submission status: Accepted

Solution code:


s = input()
sd = s[::-1]

print(len(s) - sd.index('Z') - s.index('A'))

Submission status: Accepted

Solution code:
from sys import stdin
ans = ''
s = stdin.readline().strip()
n = len(s)
for i in xrange(n):
 if s[i]=='A':
  break
for j in xrange(n):
 if s[n-1-j]=='Z':
  break
j = n-1-j
print j-i+1

Submission status: Accepted

Solution code:

s = input()

a = None
for i in range(len(s)):
    if a is None:
        if s[i] == 'A':
            a = i
    else:
        if s[i] == 'Z':
            z = i

print(z - a + 1)

Submission status: Runtime Error

Solution code:
n = input()
a = n.index("A")
n = len(n) - n[::-1].index("Z") - 1
print(len(n[a:n+1]))

Submission status: Runtime Error

Solution code:
n = input()
a = n.index("A")
n = len(n) - n[::-1].index("Z")
print(len(n[a:n+1]))

Submission status: Runtime Error

Solution code:
sample = input()
new = []
for i in sample:
  new.append(i)
if "A" in new:
  a_pos = list.index(new)
if "Z" in new:
  z_pos = list.index(new)
if a_post < z_pos:
  out = new[a_pos:(z_pos+1)]
    
new_string = ""
for j in out:
  new_string += j
print(len(new_string))

Submission status: Runtime Error

Solution code:
sample = input()
new = []
for i in sample:
  new.append(i)
if "A" in new:
  a_pos = list.index(new)
if "Z" in new:
  z_pos = list.index(new)
if a_post < z_pos:
  out = new[a_pos:(z_pos+1)]
    
new_string = ""
for i in out:
  new_string += i
print(len(new_string))

Submission status: Runtime Error

Solution code:
sample = input()
new = []
for i in sample:
  new.append(i)
if "A" in new:
  a_pos = list.index(new)
if "Z" in new:
  z_pos = list.index(new)
if a_post < z_pos:
	out = new[a_pos:(z_pos+1)]
    
new_string = ""
for i in out:
  new_string += i
print(len(new_string))

Submission status: Runtime Error

Solution code:
sample = input()
new = []
for i in sample:
  new.append(i)
if "A" in new:
  a_pos = list.index(new)
if "Z" in new:
  z_pos = list.index(new)
if a_post < z_pos:
	out = new[a_pos:(z_pos+1)]
    
new_string = ""
for i in out:
  new_string += i
print(new_string)

Submission status: Runtime Error

Solution code:
sample = input()
new = []
for i in sample:
  new.append(i)
if "A" in new:
  a_pos = list.index(new)
if "Z" in new:
  z_pos = list.index(new)
out = new[a_pos:(z_pos+1)]
print(out)

Submission status: Runtime Error

Solution code:
sample = input()
new = []
for i in sample:
  new.append(i)
if "A" in new:
  a_pos = list.index(new)
if "Z" in new:
  z_pos = list.index(new)
out = new[a_pos:z_pos +1]
print(out)

Submission status: Runtime Error

Solution code:
string = input()
index_of_A = string.index("A")
index_of_Z = string.index("Z", index_of_A, len(string)-1)

print(index_of_Z - index_of_A + 1)

Submission status: Runtime Error

Solution code:
string = input()
count = 0
for i in range(len(string)):
  if string[i] == "A":
    count = 1
    while string[i] != "Z":
      count += 1
      i += 1 
print(count+1)

Submission status: Runtime Error

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
state = False
chk2 = False
chk = 0
for i in range(len(s)):
    if state == False and s[i] == "A":
        state = True
        chk += 1
    elif state == True and s[i] == "Z":
        chk += 1
        if ans < chk:
            ans = chk
            chk2 = True
        chk = 0
        state = False
    elif state == False and s[i] == "Z" and chk2 = True:
        ans += 1
    elif state == False ans chk2 == True:
        chk2 = False
    elif state == True:
        chk += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
state = False
chk2 = False
chk = 0
for i in range(len(s)):
    if state == False and s[i] == "A":
        state = True
        chk += 1
    elif state == True and s[i] == "Z":
        chk += 1
        if ans < chk:
            ans = chk
            chk2 = True
        chk = 0
        state = False
    elif state == False and s[i] == "Z" and chk2 = True:
        ans += 1
    elif state == False ans chk2 = True:
        chk2 = False
    elif state == True:
        chk += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
state = False
chk = 0
for i in range(len(s)):
    if state == False and s[i] == "A":
        state = True
        chk += 1
    elif state == True and s[i] == "Z":
        chk += 1
        if ans < chk:
            ans = chk
        if s[i+1] == "Z":
            ans += 1
        chk = 0
        state = False
    elif state == True:
        chk += 1
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
state = False
chk = 0
for i in range(len(s)):
    if state == False and s[i] == "A":
        state = True
        chk += 1
    elif state == True and s[i] == "Z":
        chk += 1
        if ans < chk:
            ans = chk
        if s[i+1] == "Z":
            ans += 1
        chk = 0
        state = False
    elif state == True:
        chk += 1
print(ans)