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 = input()
a_list = []
z_list = []
for i in range(0, len(s)):
        if s[i] == 'A':
                a_list.append(i)
        elif s[i] == 'Z':
                z_list.append(i)
print(max(z_list) - min(a_list) + 1)

Submission status: Accepted

Solution code:
s=input()

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

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



print(z-a+1)

Submission status: Accepted

Solution code:
s = input()

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import re


def main():
    s = input()

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

    # regex = re.compile(r'A*Z')
    # 
    # match_list_len = list(map(len, regex.findall(s)))
    # print(max(match_list_len))


if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
S = input()

min_A = 0
max_Z = 0

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

print(max_Z - min_A + 1)

Submission status: Accepted

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

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

a = min(lst_a)
z = max(lst_z)
print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
row = input().split()
s = list(row[0])
Flag = 0
count = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        Flag = 1
    if s[i] == 'Z' and Flag == 1:
        ans = count

    if Flag == 1:
        count += 1

print(ans+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

S_size = len(S)

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

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

print(stop - start + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
# 入力部分を取得
# A, B, C = map(int,input().split())

# sumを取得
# sum([A,B,C])

# importするとき
# import math

# 配列に入れる
# b_list=list(map(int,input().split()))

# 一つ代入する(数値)
# e=int(input())

# 取得する
# e=input()

# 切り捨て
# math.floor((3*A + P)/2)

# stringからdatetimeへ変換
# 例1
# string_date_1 = '2017/07/01'
# atetime.datetime.strptime(string_date_1, '%Y/%m/%d')

# forの使い方
# for i in range(3):
#    print(haiku[i])
# for haiku in haikus:
#    print(haiku)

# 分割して受け取る
# haiku = haikus.split(",")

# 文字列の分割
# char_list = list(str)

# ソートする
# n = int(input())
# d = list(map(int, input().split()))
# list = sorted(d)
# print(d)


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


print(finish - start + 1)

Submission status: Accepted

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


print(finish - start + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

S = s()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
first = -1
last = -1
for i in range(0,len(s)):
    if s[i] == "A" and first == -1:
        first = i
    if s[i] == "Z":
        last = i
print(int(last - first + 1))

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

Submission status: Accepted

Solution code:
a = input()
b = 0
count = 0
d = 0 
e = []
flag = False
for i in a:
     if i == "A" and d == 0:
          b = count
          flag = True
          d += 1
     if i == "Z":
          e.append(count)
     count += 1
print(e[-1]-b+1)

Submission status: Accepted

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


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


print(gb-ga+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

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

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

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

print(len(s) - left - right)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

a_no = 0
z_no = 0

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

Submission status: Accepted

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


abc()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# from pprint import pprint

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

length = len(s)

# print(length)

minA = length
maxZ = 0

for i in range(length):
  # print("{}: {}".format(i, s[i]))
  if i < minA and s[i] == "A":
    minA = i
  
  if s[i] == "Z":
    maxZ = i

print(maxZ - minA + 1)

Submission status: Accepted

Solution code:
#文字列を取得する(QWERTYASDFZXCV)
strings = list(input())

#Aの一番小さいインデックス番号
place_smallest_A= 200000
place_largest_Z= 0

#for文で一番小さいインデックスのAを取り出す
for number in range(len(strings)):
  if strings[number] == "A":
    if number < place_smallest_A:
      place_smallest_A = number
      
#for文で一番大きいインデックスのZを取り出す
for number in range(len(strings)):
  if strings[number] == "Z":
    if number > place_smallest_A:
      place_smallest_Z = number

#A~Zの間でスライスする
ans = strings[place_smallest_A:place_smallest_Z+1]
#配列の長さを答える
print(len(ans))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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



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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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 = input()
start = s.find('A')
end = s.rfind('Z')
answer = end - start + 1
print(answer)

Submission status: Accepted

Solution code:
S = input()
a = []
z = []

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

    if S[i] == 'Z':
        z.append(i)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(end - start)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())

a=[]
z=[]

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

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

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

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

Submission status: Accepted

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

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

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

print(z-a+1)

Submission status: Accepted

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

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

print(len(S)-a-b)

Submission status: Accepted

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

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

Submission status: Accepted

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

def solve():
    s = input()

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

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

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

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

s = s[::-1]

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

Submission status: Accepted

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

    A_indexes = []
    Z_indexes = []

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - A to Z String
https://atcoder.jp/contests/abc053/tasks/abc053_b

"""
import sys


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


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


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

Submission status: Accepted

Solution code:

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = list(input())

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

print(len(s) - z - a)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
for i in range(n):
	if s[i] == "A":
		l = i
		break
for i in range(n-1,-1,-1):
	if s[i] == "Z":
		r = i
		break
print(r-l+1)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
flag1=0

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

print(finish-start+1)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

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

Submission status: Accepted

Solution code:
s = input()

idx_a = None
idx_b = 0

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

print(idx_b - idx_a + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

print(index_Z - index_A + 1)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

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

Submission status: Accepted

Solution code:
s = input()

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

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

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
A = []
Z = []

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

print(Z[-1]-A[0]+1)

Submission status: Accepted

Solution code:
s = input()
ans = 0
x = -1
for i in s:
    if i == 'A' and x == -1:
        x = 0
    if x >= 0:
        ans += 1
        x += 1
        if i == 'Z':
            x = 0

print(ans - x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

    solve(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
num_A = -1
num_Z = -1
for ind,i in enumerate(s):
  if(num_A == -1 and i == 'A'):
    num_A = ind
  if(i == 'Z'):
    num_Z = ind
print(num_Z - num_A + 1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import re

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

Submission status: Accepted

Solution code:
# ABC053B - A to Z String
s = list(input())
i = 0
while s[i] != "A":
    i += 1
j = 1
while s[-j] != "Z":
    j += 1
print(len(s) - i - j + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
s = input()

sub = 0

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

print(sub)