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()
ans=0
cnt=0
flg=False
for s in S:
    if s=="A":
        cnt+=1
        flg=True
        continue
    elif s=="Z" and flg:
        cnt+=1
        ans=cnt
        continue
    
    if flg:
        cnt+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s= input()
ans = re.findall(r"A[A-Z]*Z",s)
print(len(max(ans)))

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = s[start:(end+1)]
print(len(ans))

Submission status: Accepted

Solution code:
s = input()
index_A = float('inf')
index_Z = float('inf')
for i in range(len(s)):
    if s[i] == 'A':
        index_A = i
        break

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
s = input()
#できるだけ最初にあるAと、できるだけ最後にあるZを取る
a = s.find('A')
z = s.rfind('Z')

print(z-a+1)

Submission status: Accepted

Solution code:
s = input()

print(len(s) - list(reversed(list(s))).index('Z') - s.index('A'))

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import sys

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

def main():
    a = s.index('A')
    z = len(s) - (s[::-1].index('Z') + 1)
    return z - a + 1

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

Submission status: Accepted

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

print(left - right + 1)

Submission status: Accepted

Solution code:
s = input()
a = s.index("A")
z = s.rfind("Z")

print(z-a+1)

Submission status: Accepted

Solution code:
w=input()
first_A=None
last_Z=None
for i,v in enumerate(w):
    if v=="A" and first_A is None:
        first_A=i
    if v=="Z":
        last_Z=i
print(last_Z-first_A+1)

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()
for i in range(len(s)):
  if s[i]=="A":
    pA = i
    break
for i in range(len(s)):
  if s[-i-1] == "Z":
    pZ = i
    break
print(len(s)-pA-pZ)

Submission status: Accepted

Solution code:
s=input()
l=len(s)
a,b=0,l-1
for i in range(l):
    if s[i]=="A":
        a=i
        break
for i in range(l-1,-1,-1):
    if s[i]=="Z":
        b=i
        break
print(b-a+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()
st = s.find("A")
en = len(s) - s[::-1].find("Z")
print(en - st)

Submission status: Accepted

Solution code:
s = input()

pos_A = s.find("A")
pos_Z = s.rfind("Z")

print(pos_Z - pos_A + 1)

Submission status: Accepted

Solution code:
S = input()

first_A = None
last_Z = None

for i, c in enumerate(S):
    if c == 'A' and first_A is None:
        first_A = i
    elif c == 'Z':
        last_Z = i

print((last_Z - first_A) + 1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()

first_a = s.find("A")
last_z = s.rfind("Z")

print(last_z - first_a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = list(input())
count = len(line)
start = 0
for i in range(count):
  if line[i] == "A":
    start = i
    break

stop = 0
for j in range(count -1,0,-1):
  if line[j] == "Z":
    stop = count -1 - j
    break
    
answer = count - start - stop
print(answer)

Submission status: Accepted

Solution code:
s = input()
start = s.find('A')
end = s.rfind('Z')

ans = end - start +1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# findとrfindの使い方
s = input()
a = 0
z = 0
while True:
  a = s.find("A")
  z = s.rfind("Z")
  if s[a:z+1][0] == "A" and s[a:z+1][-1] == "Z":
    break
print(z - a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

s = input()

result = re.search(r"A.*Z", s)
print(len(result.group(0)))

Submission status: Accepted

Solution code:
[print(len(string) - string[::-1].index("Z") - string.index("A")) for string in [input()]]

Submission status: Accepted

Solution code:
s = input()

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

print(l - zi - ai)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

a_num = -1
z_num = -1

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

for j in range(len(s)):
    if list_s[j] == "Z":
        z_num = j

print(z_num - a_num + 1)

Submission status: Accepted

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

a_num = len(s)
z_num = -1

for i in range(len(s)):
    if list_s[i] == "A":
        if a_num > i:
            a_num = i

    if list_s[i] == "Z":
        z_num = i

print(z_num - a_num + 1)

Submission status: Accepted

Solution code:
S = input()

head = [i for i in range(0, len(S)) if S[i]=="A"]
tail = [i for i in range(0, len(S)) if S[i]=="Z"]

print(max(tail)-min(head)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

print(last - first+1)

Submission status: Accepted

Solution code:
s = input()

for i , v in enumerate(s):
    if v == 'A':
        apos = i + 1
        break

for i , v in enumerate(s[::-1]):
    if v == 'Z':
        zpos = len(s) - i 
        break

print( zpos - apos + 1)

Submission status: Accepted

Solution code:
s = input()

for i, v in enumerate(s):
    if v == "A":
        a_pos = i
        break

for i, v in enumerate(s[::-1]):
    if v == "Z":
        z_pos = len(s) - i
        break

print(z_pos - a_pos)

Submission status: Accepted

Solution code:
s = input()

found_a = False
high = 0
low = 0

for index, word in enumerate(s):
    if found_a == False:
        if word == 'A':
            low = index
            found_a = True
    if word == 'Z':
        high = index

print(high - low + 1)

Submission status: Accepted

Solution code:
s=input()
u=10**9
p=0
for i in range(len(s)):
    if s[i]=='A':
        u=min(u,i)
    elif s[i]=='Z':
        p=max(p,i)
print(p-u+1)

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()
frag = 0
for i in range(len(s)):
    if s[i] == "A" and frag == 0:
        first = i
        frag = 1
    if s[i] == "Z":
        last = i
print(last-first+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()
st=0
ed=0
for i,word in enumerate(s):
    if word == "A":
        st = i
        break
for i,word in enumerate(reversed(s)):
    if word == "Z":
        ed = len(s)-i
        break
print(ed-st)

Submission status: Accepted

Solution code:
s=input()
rev_s = ''.join(list(reversed(s)))
for ind,moji in enumerate(s):
    if(moji=='A'):
        start=ind
        break
for ind,moji in enumerate(rev_s):
    if(moji=='Z'):
        end=ind
        break
print((len(s)-end)-start)

Submission status: Accepted

Solution code:
S = input()
start = 0
start_check = False
end = 0
for idx, val in enumerate(S):
    if val == "A" and not start_check:
        start = idx
        start_check = True
    elif val == "Z":
        end = idx

print(end - start + 1)

Submission status: Accepted

Solution code:
s = str(input())
l = -1
r = -1
for i in range(len(s)):
    if (s[i]=='A')&(l==-1):
        l=i
    if (s[len(s)-1-i]=='Z')&(r==-1):
        r=len(s)-1-i
    if (r>=0)&(l>=0):
        break
print(r-l+1)

Submission status: Accepted

Solution code:
##### 解けた #####

import re

s=input()
m=re.search("A.*Z",s)
print(m.end()-m.start())

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    idx1 = S.index("A")
    S_r = S[::-1]
    idx2 = S_r.index("Z")
    idx2 = len(S) - 1 - idx2
    print(idx2-idx1+1)
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 = input()
a = len(s)
b = 0
for x,i in enumerate(s):
  if i == "A":
    a = min(a,x)
  elif i == "Z":
    b = max(b,x)
print(b-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])
    N = len(S)
    start = None
    for i in range(N):
        if S[i] == 'A':
            start = i
            break
    end = None
    for i in reversed(range(N)):
        if S[i] == 'Z':
            end = i
            break
    return end - start + 1


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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_index = -1
z_index = 0
for i in range(len(s)):
    if s[i] == 'A' and a_index == -1:
        a_index = i
    elif s[i] == 'Z':
        z_index = i

print(z_index-a_index+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()
start = 0
stop = 0
flg = True
for i in range(len(s)):
    if s[i] == 'A' and flg:
        start = i
        flg = False
    if s[i] == 'Z':
        stop = i
print(stop-start+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

k = -1
t = -1

for i in range(len(s)):
	if s[i]=='A':
		if k < 0:
			k = i
	elif s[i]=='Z':
		if i > t:
			t = i
print(t-k+1)

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"):
        z = i
        break
az = S[a:z]
print(len(az)+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)
        
print(z[-1] - a[0] + 1)

Submission status: Accepted

Solution code:
line = input()
a = []
z = []
for i in range(len(line)):
    if line[i] == "A":
        a.append(i)
    elif line[i] == "Z":
        z.append(i)

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

Submission status: Accepted

Solution code:
s = input()
bl = False
for i in range(len(s)):
    if s[i] == "A" and bl == False:
        cnt = 1
        bl = True
        continue
    if bl == True:
        cnt += 1
        if s[i] == "Z":
            ans = cnt
print(ans)

Submission status: Accepted

Solution code:
def main(s):
    head, tail = 0, 0

    for _s in s:
        if _s == 'A':
            break

        head += 1

    for _s in s[::-1]:
        if _s == 'Z':
            break

        tail += 1

    print(len(s) - (head + tail))


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

    main(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
m = input()
m_az = re.search("A.*Z", m)
print(len(m_az.group(0)))

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:
string = input()
a_idx = 10e9
z_idx = 0
for i, char in enumerate(string):
    if (char == "A") & (i < a_idx):
        a_idx = i
    if (char == "Z") & (i > z_idx):
        z_idx = i

print(z_idx - a_idx + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A to Z string
s = input()
judge_a = 0
judge_z = 0
a = 0
z = 0

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

print(z-a)

Submission status: Accepted

Solution code:
s = input()

start = None
for i, a in enumerate(s):
    if a == 'A':
        start = i if start is None else start
    if a == 'Z':
        end = i
print(end - start + 1)

Submission status: Accepted

Solution code:
import sys
s = input()
st=0
e=0
max=0
f=False
for i in range(len(s)):
    if s[i] == "A":
        st = i
        break

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

print(e-st+1)

Submission status: Accepted

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

start=0
end=0
for ind,i in enumerate(s):
    if(i=='A'):
        start=ind
        break

for ind,i in enumerate(rev):
    if(i=='Z'):
        end=len(s)-ind
        break

print(end-start)

Submission status: Accepted

Solution code:
def main():
  s = list(input())
  start = -1
  end = -1
  for i, c in enumerate(s):
    if start == -1 and c == 'A':
      start = i
    if start != -1 and c == 'Z' and end < i:
      end = i
  print(end - start + 1)

main()

Submission status: Accepted

Solution code:
s = list(str(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':
    z = i + 1
    break
    
print(z - a)

Submission status: Accepted

Solution code:
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
S = input().rstrip()

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

print(zi-ai+1)

Submission status: Accepted

Solution code:
s = input()
flag = True
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()
flag = True
for i in range(len(s)):
    if s[i] == "A" and flag :
        a = i
        flag = False
    if s[i] == "Z" and not flag:
        z = i
print(z-a+1)

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()
sento=2000000
matubi=0

for i in range(len(s)):
  if s[i] == "A":
    sento=min(i,sento)
for i in range(len(s)):
  if s[i] == "Z" and i > sento:
    matubi=max(i,matubi)
print(matubi-sento+1)

Submission status: Accepted

Solution code:
A = input()
count = 0
p = len(A)
min_=200000
max_=0
for i in range(p):
  if (A[i] == 'A'):
    min_ = min(i,min_)
  if (A[i] == 'Z'):
    max_ = max(i,max_)
print(max_-min_+1)

Submission status: Accepted

Solution code:
def examB():
    s = S()
    for i,j in enumerate(s):
        if j=="A":
            right = i
            break
    for i,j in enumerate(s[::-1]):
        if j=="Z":
            left = i
            break
    ans = len(s)-right-left
    print(ans)


import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 053: B – A to Z String
s = input()
s_dash = s[::-1]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    s = input()
    n = len(s)
    l = 0
    r = 0
    for i in range(n):
        if s[i] == 'A':
            l = i
            break
    for i in range(n)[::-1]:
        if s[i] == 'Z':
            r = i
            break
    print(r-l+1)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s = s

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

Submission status: Accepted

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

s = input()

sc = 0
ec = len(s)

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

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

print(ec - sc + 1)

Submission status: Accepted

Solution code:
s = list(input())
a = 200000
z = 0
# a>i , z<i　を加える事で1文字目にZが来ることと最後の文字にAが来ることを除外している。と思われる。
for i in range(len(s)):
    if s[i] == "A" and a>i:
        a = i
    elif s[i] == "Z" and z<i:
        z = i
print(z - a + 1)

Submission status: Accepted

Solution code:
n = input()

a = 0
z = 0
for index, s in enumerate(n):
  if s == 'A':
    a = index
    break

for index, s in enumerate(n):
  if s == 'Z' and index > a:
    z = index

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

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

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

print(j - i + 1)

Submission status: Accepted

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

s = input()

ans = s.rindex('Z') - s.index('A') + 1

print(ans)

Submission status: Accepted

Solution code:
s=input();l=1e9;r=0;
for i in range(len(s)):
  if s[i]=='A': l=min(l,i)
  elif s[i]=='Z'and l!=1e9:r=max(r,i)
print(r-l+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
A_index = [i for i in range(len(S)) if S[i] == "A"]
Z_index = [i for i in range(len(S)) if S[i] == "Z"]
print(len(S[A_index[0] : Z_index[-1] + 1]))

Submission status: Accepted

Solution code:
S = input()
A_index = []
Z_index = None
for i in  range(len(S)):
    if S[i] == "A":
        A_index.append(i)
    elif S[i] == "Z":
        Z_index = i
print(len(S[A_index[0]:Z_index+1]))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
p=0
q=0
r=0
m=0
for i in s:
  r +=1
  if i =='A':
    if p==0:
      p=r
  elif p!=0 and i=='Z':
    q = r
print(q-p+1)

Submission status: Accepted

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

Submission status: Accepted

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

# input
s = input()

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

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

# output
print(z - a + 1)

Submission status: Accepted

Solution code:
s = input()

start = end = -1
ans = 0
for i, _s in enumerate(s):
    if _s == "A" and start < 0:
        start = end = i
    elif _s == "Z":
        end = i
        ans = max(ans, end - start + 1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
S = input()
flag = True
for i in range(len(S)):
    if S[i] == "A" and flag:
        start = i
        flag = False
    if S[i] == "Z":
        end = i
print(end - start + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

idx_a = []
idx_z = []

for idx in range(len(s)):
    if s[idx] == "A":
        idx_a.append(idx)
    elif s[idx] == "Z":
        idx_z.append(idx)

ans = idx_z[-1] - idx_a[0] + 1
print(ans)

Submission status: Accepted

Solution code:
s = input()
a = s.index("A")

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

print(len(s) - a - z)

Submission status: Accepted

Solution code:
s = input()
a = s.index("A")

rs = ''.join(reversed(s))
z = rs.index("Z")

print(len(s) - a - z)

Submission status: Accepted

Solution code:
s = input()

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

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

length = (len(s) + z_index) - a_index + 1
print(length)

Submission status: Accepted

Solution code:
S = input()

rS = S[::-1]
indexA = S.find("A")
indexrZ = rS.find("Z")
indexZ = len(S)-indexrZ

ans = indexZ - indexA

print(ans)

Submission status: Accepted

Solution code:
s = input()
A_index = s.index('A')
s = list(s)
s.reverse()
s = "".join(s)
Z_index = len(s) - s.index('Z')     
print(Z_index - A_index)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
import itertools
import functools
import math

if __name__ == "__main__":
    s = input()
    a = s.find("A")
    z = s.rfind("Z") + 1
    print(z - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

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

print(r-l+1)

Submission status: Accepted

Solution code:
#
# abc053 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    s = input()

    S = 0
    E = len(s)
    for i in range(len(s)):
        if s[i] == "A":
            S = i
            break
    for j in reversed(range(len(s))):
        if s[j] == "Z":
            E = j+1
            break
    print(len(s[S:E]))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """QWERTYASDFZXCV"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ZABCZ"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """HASFJGHOGAKZZFEGA"""
        output = """12"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
s=input()
a=s.index("A")
z=s.index("Z")
if __name__ == "__main__":
    index_num = [n for n, v in enumerate(s) if v == "A"]
    #print (index_num)
if __name__ == "__main__":
    index_n = [n for n, v in enumerate(s) if v == "Z"]
    #print (index_n)
print(max(index_n)-min(index_num)+1)

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

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(s[a:z + 1]) # slice (don't include s[z + 1])
print(z - a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print()
print(abs(S.find('A')-S.rfind('Z'))+1)