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

Submission status: Accepted

Solution code:
s = input()
for i in range(len(s)):
    if s[i] == "A":
        min = i
        break
for i in range(len(s))[::-1]:
    if s[i] == "Z":
        max = i
        break
print(max-min+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)):
    if s[-i-1]=="Z":
        print(len(s)-i-a)
        break

Submission status: Accepted

Solution code:
s = input()
c1 = 0
c2 = 0
for i in s:
    if i == "A":
        break
    c1 += 1
    
for i in reversed(s):
    if i == "Z":
        break
    c2 += 1
    
print(len(s)-c2-c1)

Submission status: Accepted

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

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 = str(input())
start=0
end = 0
for i,j in enumerate(s):
  if j == "A":
    start = i
    break
for i,j in enumerate(s[::-1]):
  if j == "Z":
    end = i
    break
print(len(s) - start - end)

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)):
    p = len(s) - 1 - i
    if s[p] == 'Z':
        end = p
        break
print(end - start + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
num = 0
num2 = 0
for i in range(len(S)):
    if S[i] == "A":
        num = i
        break
for i in range(len(S)):
    if S[i] == "Z":
        num2 = i

print(num2 - num + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

for n, i in enumerate(s):
    if i=='A':
        a=n
        break
for n, i in enumerate(reversed(s)):
    if i=='Z':
        b=len(s)-n
        break

print(b-a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    s = list(input())
    ans = 0
    ss = -1
    e = -1
    for i,val in enumerate(s):
        if val == "A":
            ss = i
            break
            
    s = s[::-1]
    for i,val in enumerate(s):
        if val == "Z":
            e = i
            break
            
    #print("{} {} {}".format(len(s),e,ss))
    print((len(s)-e)-ss)
            
            
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(s: str):
    start = s.find("A")
    end = s.rfind("Z")
    print(end-start+1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
a=[]
z=[]
for i in range(n):
  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()
left = s.index('A')
for i in range(len(s)-1, 0, -1):
    if s[i] == 'Z':
        right = i
        break

print(len(s[left:right+1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
S = stdin.readline()
flag = 0
a_pos = 0
z_pos = 0
for c, s in enumerate(S):
    if (s == "A") & (flag == 0):
        flag = 1
        a_pos = c
    if s == "Z":
        z_pos = c
print(z_pos - a_pos + 1)

Submission status: Accepted

Solution code:
x = [i for i in input()]
p = x.index("A")
t = [i for i,x in enumerate(x) if x == "Z"]
q = max(t)
print(q-p+1)

Submission status: Accepted

Solution code:
S=input()
a=S.index('A')
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:
S = input()
#print(s.index("Z")-s.index("A")+1)
Z = [i for i,j in enumerate(S) if j == 'Z']
print(Z[-1]-S.index("A")+1)

Submission status: Accepted

Solution code:
s = input()
length = len(s)
start =0
end=0

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

print(end-start+1)

Submission status: Accepted

Solution code:
s = str(input())
ptA = s.find("A")
ptB = s.rfind("Z")
print(ptB-ptA+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:
import re
s = input()
start =s.index('A')
end =s.index('Z')
for i in s:
  if i == 'A':
    start = s.find('A')

#s_r =list(reversed(s))
end =s.rfind('Z')
print(end-start+1)

Submission status: Accepted

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

Submission status: Accepted

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

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 = input()
a = 0
z = 0
for i in range(len(s)):
    if s[i] == 'A' and a == 0:
        a = i + 1
    if s[-i] == 'Z' and z == 0 and i != 0:
        z = len(s) -i + 1
print(z - a + 1)

Submission status: Accepted

Solution code:
a = input()

b = a.find("A")+1
c = a.rfind("Z")+1

print(c-b+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

a_pos = -1
z_pos = -1

for i, si in enumerate(s):
    if si == 'A' and a_pos == -1:
        a_pos = i
    if si == 'Z':
        z_pos = i

print(z_pos - a_pos + 1)

Submission status: Accepted

Solution code:
s = input()

a_pos = s.find('A')
z_pos = "".join(reversed(s)).find('Z')
z_pos = len(s) - z_pos - 1

# print(a_pos, z_pos)
print(z_pos - a_pos + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
a = 0
z = 0
for i in range(len(s)):
    if s[i] == 'A':
        a = i+1
        break
for i in range(1, len(s)):
    if s[-i] == 'Z':
        z = len(s)-i+1
        break
print(z-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_iter=0
z_iter=0
for i in range(len(s)):
  if s[i]=="A":
    a_iter=i+1
    break
for i in range(1,len(s)+1):
  if s[-i]=="Z":
    z_iter=(len(s)-1)-(i-1)
    break
print(z_iter-a_iter+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()

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

for i in range(len(a)):
  if i != 0 and 'Z' in a[-i]:
    c = i
    break
      
d = len(a) - c + 1
#print(b,c)
print(len(a[b:d]))

Submission status: Accepted

Solution code:
s = input()

aidx_list = []
zidx_list = []

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

print(len(s[aidx_list[0]:zidx_list[-1]+1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
Strings = input()

for i in range(0,len(Strings)):
    if Strings[i] == "A":
        length = i
        break

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

print(length2 - length +1 )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sl=list(input())

n=len(sl) 
al=[];zl=[]
ans=[]
for i in range(n) :
  if sl[i]=="A" :
    al.append(i)
  if sl[i]=="Z" :
    zl.append(i)
#for j in range(min(al),max(zl)+1) :
#  ans.append(sl[j])
print(max(zl)+1-min(al))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
#ABC053b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

Solution code:
strInp = input()
print(abs(strInp.find('A',0) - strInp.rfind('Z',0)) + 1)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
a = 0
z = -1
while True:
  if s[a] == 'A':
    break
  a += 1
  n -= 1
while True:
  if s[z] == 'Z':
    break
  z -= 1
  n -= 1
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

s = input().strip()

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

Submission status: Accepted

Solution code:
import re

s = input()
list_s = [len(i) for i in re.findall("A.*Z", s)]
print(max(list_s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
min = 0
flg = 0
max = 0
for i in range(len(s)):
    if s[i] == 'A':
        if flg == 0:
            min = i
            flg = 1
    
    if s[i] == 'Z':
        max = i

ans = max - min + 1
print(ans)

Submission status: Accepted

Solution code:
string = input().rstrip("\n")
string_r = "".join(reversed(string))
print(len(string) - string_r.index("Z") - string.index("A"))

Submission status: Accepted

Solution code:
s = input()
start = len(s)
end = len(s)

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

print(len(s)-start-end)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

print(indexz - indexa + 1)

Submission status: Accepted

Solution code:
s = str(input())
for i in range(len(s)):
    if s[i] == 'A':
        min = i
        break
for i in reversed(range(len(s))):
    if s[i] =='Z':
        max = i
        break

print(max-min+1)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
a = float('INF')
z = 0
for i in range(n):
    if s[i] == 'A':
        a = min(a, i)
    elif s[i] == 'Z':
        z = max(z, i)
print(z + 1 - a)

Submission status: Accepted

Solution code:
S = input()
start = 0
is_found_a = False
ans = 0
for i in range(len(S)):
    if not is_found_a and S[i] == 'A':
        start = i
        is_found_a = True
    elif S[i] == 'Z':
        ans = i - start + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
apos = -1
zpos = 0
 
for i, c in enumerate(s):
  if c == "A" and apos == -1:
    apos = i
  if c == "Z":
    zpos = i
    
print(zpos - apos + 1)

Submission status: Accepted

Solution code:
S = input()
pos_a = -1
pos_z = -1
for i in range(len(S)):
  if S[i] == 'A' and pos_a < 0:
    pos_a = i
  if S[len(S)-i-1] == 'Z' and pos_z < 0:
    pos_z = len(S)-i-1
  if pos_a >= 0 and pos_z > 0:
    break
print(pos_z-pos_a+1)

Submission status: Accepted

Solution code:
str_list = list(input())

A_index = [i for i, s in enumerate(str_list) if s == 'A']
Z_index = [i for i, s in enumerate(str_list) if s == 'Z']

print(Z_index[-1] - A_index[0] + 1)

Submission status: Accepted

Solution code:
s = input()
numA = 0
for i in range(len(s)):
    if s[i] == 'A':
        numA = i + 1
        break

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

Submission status: Accepted

Solution code:
s=list(input())

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

Submission status: Accepted

Solution code:
s = input()

l_counter = 0
r_counter = 0
onthelist =False
ans = 0
for l in s:
    if l == 'A':
        break
    l_counter += 1

for l in s[::-1]:
    if l == 'Z':
        break
    r_counter += 1


ans = len(s) - l_counter - r_counter

# print(l_counter, r_counter, len(s))
print(ans)

Submission status: Accepted

Solution code:
S = input()
s = None
for i in range(len(S)):
  c = S[i]
  if c == "A" and s is None:
    s = i
  if c == "Z":
    e = i
print(e-s+1)

Submission status: Accepted

Solution code:
S = input()
L = len(S)
for i in range(L):
  c = S[i]
  if c == "A":
    s = i
    break
for i in range(L):
  c = S[-(i+1)]
  if c == "Z":
    e = L - (i+1)
    break
print(e-s+1)

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

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

Submission status: Accepted

Solution code:
s = str(input())
a = -1
z = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(s: str):
    a = s.find('A')
    z = ''.join(list(reversed(s))).find('Z')
    print(len(s) - z - a)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
e=10**9
for i,S in enumerate(s):
  if S=='A':
    b=i
    break
for i,S in enumerate(s[::-1]):
  if S=='Z':
    e=len(s)-i
    break
print(e-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
s = s.split("A",1)[1]
s = s.rsplit("Z",1)[0]
print(len(s)+2)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys

def main():
    data = list(input())

    for i in range(len(data)):
        if data[i] == 'A':
            left = i
            break

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

    print(right - left + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())
count = 0
index1 = s.index("A")
    
for num in s[::-1]:
  if num == "Z":  
    break
  else :
    count += 1

print(len(s) - (index1 + count))

Submission status: Accepted

Solution code:
s = list(input())
i = s.index("A")
s.reverse()
j = s.index("Z")
print(len(s) - j -  i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
b = 0
count = 0
while True:
  if a[count] == "A":
    b = count
    break
  else:
    count += 1
count = 1
while True:
  if a[-count] == "Z":
    print(len(a)-count-b+1)
    exit()
  else:
    count += 1

Submission status: Accepted

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

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

print(e-s+1)

Submission status: Accepted

Solution code:
s = input()

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

print(b - a + 1 )

Submission status: Accepted

Solution code:
s = list(input())
len = len(s)
fastA = s.index("A")+1
s.reverse()
Ztsal = s.index("Z")+1
lastZ = len - Ztsal + 1
print(lastZ - fastA + 1)

Submission status: Accepted

Solution code:
s = input()
start = 200030
end = 0

for i in range(len(s)):
    if s[i] == "A":
        if i < start:
            start = i
        
    elif s[i] == "Z":
        end = i

print(end - start + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

while True:
  for i, n in enumerate(s):
    if n == "A":
      inda = i
      break
  break

while True:
  for i, n in enumerate(s[::-1]):
    if n == "Z":
      indz = i
      break
  break

indz = len(s) - indz - 1
print(indz - inda + 1)

Submission status: Accepted

Solution code:
s = list(input())

res = 0
count = 0
for i in range(len(s)):
    if s[i] == 'A':
        for j in range(i, len(s)):
            count = count + 1
            if s[j] == 'Z':
                res = max(res, count)
        break

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(str(z - a + 1))

Submission status: Accepted

Solution code:
s = input()
min_A = 200000
max_Z = 0
flag_A = False
for i in range(len(s)):
    if(flag_A==False and s[i] == 'A'):
        flag_A = True
        min_A = i
    if(s[i] == 'Z'):
        max_Z = i
print(max_Z-min_A + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return

#B
def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "A":
            a = min(a, num)
        if si == "Z":
            z = max(z, num)
    print(z-a+1)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

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

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

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

print(z-a+1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(s: str):
    l, r = -1, -1
    for i, c in enumerate(s):
        if c == 'A' and l < 0:
            l = i
        if c == 'Z':
            r = i
    ret = r - l + 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC 53, B - A to Z string
S = list(input())

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
a=[]
z=[]
for i in range(n):
    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()
a=s.find("A")
b=s.rfind("Z")
print(b+1-a)

Submission status: Accepted

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

print(f-s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
left = -1
for i in range(len(s)):
    if s[i] == "A" and left == -1:
        left = i
    elif s[i] == "Z":
        right = i
print(len(s[left:right+1]))

Submission status: Accepted

Solution code:
s = input()

i = s.find('A')
j = s[::-1].find('Z')

print(len(s) - j - i)

Submission status: Accepted

Solution code:
def main():
    s=list(input())
    s_rev = reversed(s)
    h = 0
    t = -1
    for num,i in enumerate(s):
        if i =='A':
            h = num
            break
    for num,i in enumerate(s_rev):
        if i == 'Z':
            t = len(s)-num
            break
    print(t-h)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']

print(max(index_Z) - s.index('A') + 1)

Submission status: Accepted

Solution code:

s = input()

lis = list(s)
lis.reverse()

rs = "".join(lis)

ans = len(s)


for i in range(len(s)):

    if s[i] == "A":

        ans -= i
        break

for i in range(len(rs)):

    if rs[i] == "Z":

        ans -= i
        break

print (ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = str(input())

A_list = []
Z_list = []

for i in range(len(X)):
  if X[i] == 'A':
    A_list.append(i)
  if X[i] == 'Z':
    Z_list.append(i)

print(int(Z_list[-1] - A_list[0] + 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re


s = str(input())

pattern = r"A.*Z"

X = re.search(pattern, s)

print(len(X.group()))

Submission status: Accepted

Solution code:
s = str(input())
for i in range(len(s)) :
    if s[i] == 'A' :
        leftCnt = i
        break
for i in range(len(s)) :
    if s[-1-i] == 'Z' :
        rightCnt = len(s) - i
        break
print(rightCnt - leftCnt)

Submission status: Accepted

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

pattern = re.compile('A.*Z')
ans = 2 ** 18

s = input()

for m in pattern.findall(s):
  length = len(m)
  if length < ans:
    ans = length
    
print(ans)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)
idx_a = 0
idx_z = 0
for n in range(l):
    if s[l-n-1] == 'A':
        idx_a = l-n-1
    if s[n] == 'Z':
        idx_z = n
    
print(idx_z-idx_a+1)

Submission status: Accepted

Solution code:
s = input()
a = 0
z = 200001
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:
s = input()
ai, zi = None, 0
for i in range(len(s)):
    if ai is None and s[i] == 'A':
        ai = i

    if s[i] == 'Z':
        zi = i

print(zi - ai + 1)

Submission status: Accepted

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

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

ans = endZ - startA +1
print(ans)