Problem:


Score : 200 points

Problem Statement

Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s).

Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with A and ends with Z.

Constraints

1 ≦ |s| ≦ 200{,}000

s consists of uppercase English letters.

There exists a substring of s that starts with A and ends with Z.

Input

The input is given from Standard Input in the following format:

s

Output

Print the answer.

Sample Input 1

QWERTYASDFZXCV

Sample Output 1

5

By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.

Sample Input 2

ZABCZ

Sample Output 2

4

Sample Input 3

HASFJGHOGAKZZFEGA

Sample Output 3

12



Sample input:
QWERTYASDFZXCV


Sample output:
5

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

A = s.find('A')

i = 0

for s_i in reversed(s):
    if s_i == 'Z':
        break
    i += 1

Z = len(s) - i - 1

print(Z-A+1)

Submission status: Accepted

Solution code:
s = list(input())

begin = s.index("A")
end = list(reversed(s)).index("Z")
print(len(s[begin:len(s)-end]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
while S[0]!="A":
    S=S.lstrip(S[0])
while S[-1]!="Z":
    S=S.rstrip(S[-1])
print(len(S))

Submission status: Accepted

Solution code:
s = input()
a_idx = 0
z_idx = len(s)
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=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
    if find_a==0:
        if s[a]=="A":
            find_a=1
        else:
            a+=1
    if find_z==0:
        if s[z]=="Z":
            find_z=1
        else:
            z-=1
print(z-a+1)

Submission status: Accepted

Solution code:
s=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
    if find_a==0 and s[a]=="A":
        find_a=1
    if find_z==0 and s[z]=="Z":
        find_z=1
    if find_a==0:
        a+=1
    if find_z==0:
        z-=1
print(z-a+1)

Submission status: Accepted

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


s = input().strip()
#----------
loc_A=len(s)+1
loc_Z=-1
for i in range(len(s)):
    if s[i] == "Z" and loc_Z < i:
        loc_Z = i
    elif s[i] == "A" and i < loc_A:
        loc_A = i

print( loc_Z - (loc_A - 1) )

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = s.index('A')
z = rs.index('Z')

print(len(s)-z - a )

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
A = input()
N = len(A)
for i in range(N):
    if A[i] == "A":
        posA = A.index(A[i])
        break
p = 0
for j in range(0, N):
    if A[j] == "Z" and j > p:
        p = j
p += 1
print(len(A[posA:p]))

Submission status: Accepted

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

def main():
    s = input()
    min_a_index = min([i for i, c in enumerate(s) if c == "A"])
    max_z_index = max([i for i, c in enumerate(s) if c == "Z"])
    print(max_z_index - min_a_index + 1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

id_a = len(s)
id_z = 0
for i in range(len(s)):
  if s[i] == 'A':
    id_a = min(id_a, i)
  if s[i] == 'Z':
    id_z = max(id_z, i)
    
print(id_z - id_a + 1)

Submission status: Accepted

Solution code:
s = input()

Min_a = len(s)
Max_z = 0

for i in range(len(s)):
  if s[i] == "A":
    if i < Min_a:
      Min_a = i
  elif s[i] == "Z":
    if Max_z < i:
      Max_z = i
  
ans = Max_z - Min_a + 1

print(ans)

Submission status: Accepted

Solution code:
# 53

s = str(input())

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

print(z-a+1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

def idx_z(s, key):
    for i in range(len(s)-1,0,-1):
        if s[i]==key: return i

pos_Z = idx_z(s,'Z')
pos_A = s.index('A')
print(int(pos_Z)-int(pos_A)+1)

Submission status: Accepted

Solution code:
s = input()
print(max([i for i, x in enumerate(s) if x == 'Z'])-min([i for i, x in enumerate(s) if x == '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 = int(S.find("A"))
Z = int(S.rfind("Z"))

print(Z-A+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

ans=0
a=10**6
z=-1
for i in range(len(s)):
    if s[i]=="A":
        a=min(a,i+1)
    if s[i]=="Z":
        z=max(z,i+1)
ans=z-a+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = s.index("A")
zList = [i for i , name in enumerate(s) if name == "Z"]
z = zList[-1]
print(z - a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

max = -1
buf = []
flag = False

for i in range(len(s)):
    if flag == True:
        buf.append(s[i])
        if s[i] == 'Z':
            if len(buf) >= max:
                max = len(buf)
    elif s[i] == 'A':
        buf.append(s[i])
        flag = True

print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
counter_A = 0
counter_Z = 0
for i in s:
    if i == 'A':
        break
    else:
        counter_A += 1
for i in s[::-1]:
    if i == 'Z':
        break
    else:
        counter_Z += 1
print(len(s) - counter_A - counter_Z)

Submission status: Accepted

Solution code:
s = input()
first_A = 200000
last_Z = 0

for index, word in enumerate(s):
    if word == "A":
        if first_A >= index:
            first_A = index
    if word == "Z":
        if last_Z <= index:
            last_Z = index

ans = last_Z - first_A + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

s=input()
a=-1
z=-1

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

Submission status: Accepted

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


def main():
    S = list(input())
    print(len(S) - S[::-1].index('Z') - S[::1].index('A'))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = s.find('A')
r = s.rfind('Z')
ans = len(s[l:r+1])
print(ans)

Submission status: Accepted

Solution code:
str = input()
count = 0
isCount = False
answer = 0
for id in range(len(str)):
    if isCount == False and str[id] == "A": 
        count = 0
        isCount = True
    if isCount == False: continue
    count += 1
    if str[id] == "Z": 
        answer = max(answer, count)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s_raw = list(map(str, input()))
ans = []

for i in range(0, len(s_raw)):
	if s_raw[i] == 'A':
		for k in range(i, len(s_raw)):
			ans.append(s_raw[k])
		break

for i in range(0, len(ans)):
	if ans[i] == 'Z':
		index = i
		
print(index + 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = list(str(input()))

numberA = []
numberZ = []
for i in range(len(s)):
    if s[i] == 'A':
        numberA.append(i)
    if s[i] == 'Z':
        numberZ.append(i)
print(max(numberZ) - min(numberA) + 1)

Submission status: Accepted

Solution code:
s = input()

start = []
end = []
for i in range(len(s)):
    if s[i] == "A":
        start.append(i)
    if s[-(i+1)] =="Z":
        end.append(len(s)-i)
print(end[0]-start[0])

Submission status: Accepted

Solution code:
a = input()
import re
start = re.search(r"^[^A]*A", a).end()
goal = re.search(r"Z[^Z]*$", a).start()
print(goal - start + 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
import collections
from collections import deque
list_A = deque()
list_Z = deque()
for i in range(len(s)) :
    if s[i] == "A" :
        list_A.append(i)
    if s[i] == "Z" :
        list_Z.append(i)
print(list_Z[-1] - list_A[0] + 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:
s = list(input())
front = 0
back = 0
for i in range(len(s)):
    if s[i] == 'A':
        front = i
        break
for i in range(len(s)):
    if s[i] == 'Z':
        back = i
print(back - front +1)

Submission status: Accepted

Solution code:
w=input()
for i in range(len(w)):
    a=w.find('A')
    b=w.rfind('Z')
print(b-a+1)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = input()

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
idx_a = 0
idx_z = 0
for i in range(len(s)):
    if s[i] == "A": 
        idx_a = i
        break
for i in range(len(s)-1,0,-1):
    if s[i] == "Z": 
        idx_z = i
        break
print(idx_z - idx_a + 1)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().decode('utf8')
print(-S.find('A') + S.rfind('Z') + 1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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':
        b = len(s)-i-1
        break

print(b-a+1)

Submission status: Accepted

Solution code:
s = str(input())

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

print(z-a+1)

Submission status: Accepted

Solution code:
s = input()

id_a = len(s)
id_z = 0
for i in range(len(s)):
  if s[i] == 'A':
    id_a = min(id_a, i)
  if s[i] == 'Z':
    id_z = max(id_z, i)
    
print(id_z - id_a + 1)

Submission status: Accepted

Solution code:
s = input()

left, right = s.find('A'), s.rfind('Z')
print(right-left+1)

Submission status: Accepted

Solution code:
s = input()

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

print(ans)

Submission status: Accepted

Solution code:
s=str(input())
can=0
ans=int(0)
for i in range(len(s)):
    if s[i]=='A':
        can=1
    
    if can:
        ans+=1

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

Submission status: Accepted

Solution code:
s = input()
first = s.index('A')
reversed_s = list(reversed(s))
last = len(s) - reversed_s.index('Z')
print(last-first)

Submission status: Accepted

Solution code:
s = input()

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

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

if end > start:
    print(end - start)
else:
    print(0)

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(len(s[i:j+1]))

Submission status: Accepted

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

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
        break
        
print(z-a)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_rev = s[::-1]
len = len(s)
for i in s:
    if i == "A":
        break
    else:
        len -= 1
for k in s_rev:
    if k == "Z":
        break
    else:
        len -= 1
print(len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    S = input()

    # print(S)

    head = S.index("A")
    tail = S[::-1].index("Z")
    tail = len(S) - tail

    return S[head:tail]


if __name__ == '__main__':
    res = solve()
    print(len(res))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s = input()
pattern = 'A.*Z'
print(len(re.search(pattern, s, flags=0).group()))

Submission status: Accepted

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

print(len-a-z)

Submission status: Accepted

Solution code:
#python3
def main():
    s = input()
    A_index = s.index('A')
    t = [i for i in reversed(s)]
    Z_index = len(s) - t.index('Z') - 1

    if Z_index - A_index >= 0:
        print(Z_index - A_index + 1) 

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    S=STR()
    sl=len(S)
    for i in range(sl):
        if S[i]=='A':
            cta=i
            break
    for i in range(sl):
        if S[(sl-1)-i]=='Z':
            ctz=sl-1-i
            break
    print(ctz-cta+1)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
string = input()

len = len(string)

for s in string:
    if s == "A":
        break
    else:
        len -= 1

for s in string[::-1]:
    if s == "Z":
        break
    else:
        len -= 1

print(len)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
l=[]
for i,v in enumerate(a):
    if v=="Z":
        l.append(i)
print(int(l[-1])-a.index("A")+1)

Submission status: Accepted

Solution code:
s=input()
a=s.index('A')
while len(s)>=2:
    if s[-1]=='Z':
        print(len(s[a:]))
        break
    else:
        s=s[:-1]

Submission status: Accepted

Solution code:
s = input()
f = s.index("A")
l = 0

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

print(l-f)

Submission status: Accepted

Solution code:
import re
s = input()
print(len(re.findall('A.*Z', s)[0]))

Submission status: Accepted

Solution code:
s=list(input())
a=0 #aを見つけたか
ans=1
z_index=0
for i in range(len(s)):
    if a==0 and s[i]=="A":
        ans-=i
        a=1
        #print(i)
    if a==1 and s[i]=="Z":
        z_index=i
        #print(i)
print(ans+z_index)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 050 - B
# -*- encoding: UTF-8 -*-

s = input()

slist = list(s)

aindex = slist.index("A")

slist.reverse()
zindex = slist.index("Z")

length = len(slist) - aindex - zindex
print(length)

Submission status: Accepted

Solution code:
s = input()

A_index = s.index("A")

for i in range(len(s)):
    if s[i] == "Z":
        Z_index = i

print(Z_index - A_index + 1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
s=input().strip()
for i in range(len(s)):
    if s[i]=="A":
        sa=i
        break
for i in range(len(s)):
    if s[i]=="Z":
        sz=i
print(len(s[sa:sz+1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
l=len(s)
for i in range(l):
  if s[i]=="A":
    flga=i
    break
for i in range(l):
  if s[i]=="Z":
    flgz=i

print(flgz-flga+1)

Submission status: Accepted

Solution code:
string = input()

start = -1
end = -1
for i, s in enumerate(string):
	if start == -1 and s == 'A':
		start = i
	if s == 'Z':
		end = i

print(end - start + 1)

Submission status: Accepted

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

print(z-a)

Submission status: Accepted

Solution code:
s = input()
cnt = 0
st = 0
ans = 0

for c in s:
    if c == "A": 
        st = 1
    if st == 1: 
        cnt += 1
        if c == "Z": 
            ans = cnt

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
s = input().rstrip()
s_rev = s[::-1]
mina = -1
maxz = -1
for i in range(len(s)):
    if s[i] == "A":
        mina = i
        break
for j in range(len(s)):
    if s[j] == "Z":
        maxz = max(maxz, j)
print(maxz - mina + 1)

Submission status: Accepted

Solution code:
s = input()

A_id = -1
Z_id = -1

#一番左のAと一番右のZを抽出する
for i in range(len(s)):
    if s[i]=='A':
        A_id = i
        break

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

print(Z_id - A_id + 1)

Submission status: Accepted

Solution code:
S = input()

a = 0
z = 0

for i in range(len(S)):
  if S[i] == "A":
    a = i
    break
for i in range(len(S))[::-1]:
  if S[i] == "Z":
    z = i
    break
print(z - 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:
a = input()
l = len(a) - a.index('A') - a[::-1].index('Z')
print(l)

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(s.rfind('Z') - s.find('A') + 1)

## 下記は正答だが処理時間が長すぎたケース
# betweenLength = []
# for i in range(len(s)):
#     if s[i] == 'A':
#         for j in range(len(s)):
#             if i < j and s[j] == 'Z':
#                 betweenLength.append(len(s[0:j]) + 1 - len(s[0:i]))

# print(max(betweenLength))

Submission status: Accepted

Solution code:
s = list(input())
count_max = 0
count_on = False
for i in range(len(s)):
    if count_on != True and s[i]=="A" :
       count_stt = i
       count_on = True
    if count_on == True and s[i]=="Z" :
        count_end = i
print(count_end - count_stt+1)

Submission status: Accepted

Solution code:
import re

s = input()

pattern = r'A.+Z'

res = re.findall(pattern,s)

print(len(res[0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
a,b=0,0
for i in range(n):
    if s[i]=="A":
        a=i
        break
for i in range(n-1,-1,-1):
    if s[i]=="Z":
        b=i
        break
print(b-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 reversed(range(len(s))):
    if s[i] == 'Z':
        z_index = i
        break

print(z_index - a_index + 1)

Submission status: Accepted

Solution code:
s=input()

A = -1
Z = 0

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

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":
        a = i
        break
for i in range(1, len(s)):
    if s[-i] == "Z":
        z = i
        break
print(len(s)-a-z+1)

Submission status: Accepted

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

s = input()
res = re.search('A.*Z', s)
print(len(res.group()))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
index_a = 0
index_z = -1
for i in range(len(s)):
  if s[i] == 'A':
    index_a = i
    break
    
for i in reversed(range(len(s))):
  if s[i] == 'Z':
    index_z = i
    break

print(index_z - index_a + 1)

Submission status: Accepted

Solution code:
s = input()

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

if (a >= 0 and z >= 0):
   print(z - a + 1)
else:
   print(0)

Submission status: Accepted

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

x = []

for i in range(n):
    if 'A' not in x and s[i] is 'A':
        x.append(i)
        x.append('A')
    elif 'A' in x and s[i] is 'Z':
        x.append(i)

print(x[-1] - x[0] + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = input()

first = len(s)
last = 0
for i in range(0, len(s)):
    if s[i] == "A":
        first = min(first, i)
    if s[i] == "Z":
        last = max(last, i)
#print(first, last)
print(len(s[first:last+1]))

Submission status: Accepted

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

S = input()

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] == 'A':
        ans -= i
##        print('i')
        break

for j in reversed(range(0, n)):
    if s[j] == 'Z':
        ans += j
        break

print(ans + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(tmp[1]-tmp[0]+1)

Submission status: Accepted

Solution code:
s=list(input())
a=s.index('A')+1
s.reverse()
b=len(s)-s.index('Z')

print(b-a+1)

Submission status: Accepted

Solution code:
#053 b-a to z string
s=input()
a=0
z=0
flag=True
for i in range(len(s)):
    if flag:
        if s[i]=="A":
            a=i
            flag=False
    if s[i]=="Z":
        z=i
ans=len(s[a:z+1])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
num_first = 0
num_last = 0
for i in range(len(S)):
    if S[i] == 'A':
        num_first = i
        break
S.reverse()
for j in range(len(S)):
    if S[j] == 'Z':
        num_last = len(S) - j
        break
print(num_last - num_first)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

count = 0
count_temp = 0
A_index = S.index("A")

for i in range(A_index, len(S), 1):
    count_temp = count_temp + 1

    if S[i]=="Z":
        count = count_temp
        continue
print(count)

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s=list(input())
r=list(reversed(s))
acon=0
zcon=0
for i in range(len(s)):
  if s[i]=="A":
    break
  else:
    acon+=1
for i in range(len(s)):
  if r[i]=="Z":
    break
  else:
    zcon+=1
print(len(s)-(acon+zcon))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
#if s.rfind('Z')-s.find('A')>=0:
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:
s=input()
sr=s[::-1]
a=s.index("A")
z=sr.index("Z")
print(len(s)-z-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)-1,-1,-1):
    if s[i]=='Z':
        ans=(i+1)-f
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#53b
s = str(input())
start = s.find('A')
last = s.rfind('Z')
#print(start,last)
print(last - start + 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') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1

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