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()
l = s.find('A')
r = s.rfind('Z') + 1
print(len(s[l:r]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

Submission status: Accepted

Solution code:
s = input()

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

print(end - begin + 1)

Submission status: Accepted

Solution code:
s = list(input())

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

print(end - begin + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:


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


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

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

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

def submit():
    s = read_input()

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

    print(zi - ai + 1)

if __name__ == '__main__':
    submit()

Submission status: Accepted

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

print(Z_idx-A_idx+1)

Submission status: Accepted

Solution code:
# 入力
s=input()

# 'A'と'Z'の位置を保存する変数
a=z=-1

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

# 出力
print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# print(start, goal)
ans = goal - start + 1

print(ans)

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

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)

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

Submission status: Accepted

Solution code:
import re
s = input()

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

Submission status: Accepted

Solution code:
s=input()

a=s.find("A")

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

Submission status: Accepted

Solution code:
s=input()

a=s.find('A')

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s = input()
a = re.search(r'A.*Z',s)
#print(a)
print(a.end()-a.start())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:UTF-8
s = input()
count = len(s)
print(s.rfind("Z")-s.find("A")+1)

Submission status: Accepted

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

Submission status: Accepted

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

# https://atcoder.jp/contests/abc053/tasks/abc053_b

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

    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)

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

print(l - a - z)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# -*- coding utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(end - pos + 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=input()
print(s.rfind('Z') - s.find('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:
s = list(input())
rs = list(reversed(s))


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
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

#A
"""
x = I()
if x < 1200:
    print("ABC")
else:
    print("ARC")
"""
#B
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)
#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
"""
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)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

A = S.find("A")
Z = S.rfind("Z")

print(Z - A + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = list(input())

rev_s = list(reversed(s))

n = len(s)

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

print(z-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input();print(s.rindex("Z")-s.index("A")+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()
a=s.index('A')
z=len(s) - s[::-1].index('Z')
print(z-a)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
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]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力
s = input()

# 処理
left_A  = -1  # 最も左のAの位置
right_Z = -1  # 最も右のZの位置

for i in range(len(s)):
  # left_A < 0 => まだAを見つけていない
  if left_A < 0 and s[i] == "A":
    left_A = i
  if s[i] == "Z":
    right_Z = i

# 答え
print(right_Z - left_A + 1)

Submission status: Accepted

Solution code:
s = list(input())

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

print(b - a)

Submission status: Accepted

Solution code:
# python template for atcoder1
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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_a,index_z)
print(index_z - index_a + 1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
#a,b,k = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

index1 = s.index('A')
s.reverse()
index2 = s.index('Z')
index2 = (len(s)-1) - index2
print(index2 - index1 + 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 j in range(start, len(s)):
    if s[j] == 'Z':
        end = j
print(end-start+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
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)