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

left = -1

for i,s in enumerate(S):
    if s == 'A':
        left = i
        break

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

if left < right:
    print(right-left+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
left=0
while S[left]!='A':
    left+=1
right=len(S)-1
while S[right]!='Z':
    right-=1
print(right-left+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()

for i in range(len(a)):
    if a[i]=="A":
        b=i 
        break
for j in range(len(a)-1,0,-1):
    if a[j]=="Z":
        c=j
        break
print(c-b+1)

Submission status: Accepted

Solution code:
a=input()

for i in range(len(a)):
    if a[i]=="A":
        b=i 
        break
for j in range(len(a)-1,-1,-1):
    if a[j]=="Z":
        c=j
        break
print(c-b+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
# s=int(input())
b=input()
c=[]
for i in b:
    c.append(i)
#a = list(map(int,input().split()))
#b = list(map(int,input().split()))

a1=c[c.index("A"):]
a2=[i for i, x in enumerate(a1) if x=="Z"]
print(len(a1[:a2[-1]+1]))

Submission status: Accepted

Solution code:
s = list(input())

while s[0] != 'A' or s[-1] != 'Z':
    if s[0] == 'A':
        s.pop()
    elif s[-1] == 'Z':
        s.pop(0)
    else:
        s.pop(0)
        s.pop()

print(len(s))

Submission status: Accepted

Solution code:
s = input()
begin = 0
end = 0
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':
        end = i
        break
print(end-begin+1)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
first, last = 0,0

for i in range(n):
  b,f = i+1, n-i
  if s[-1-i] == 'A':
    first = f
  if s[i] == 'Z':
    last = b

# print(first, last)
print(last - first+1)

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 = input()
sr = s[::-1]

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

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

print(en - st + 1)

Submission status: Accepted

Solution code:
s = input()
a = len(s)
z = 0
for i,e in enumerate(reversed(s)):
  if e == "A":
    a = len(s) - i -1 
for i,e in enumerate(s):
  if e == "Z":
    z = i

print(z-a+1)

Submission status: Accepted

Solution code:
s = list(input())

A = s.index("A")

S = list(reversed(s))
Z = S.index("Z")

print(len(s) - Z - A)

Submission status: Accepted

Solution code:
s = input()
first = -1
end = 0
i = 0
for c in s:
    if first == -1 and c == 'A':
        first = i
    if c == "Z":
        end = i
    i += 1
print(end - first + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

first_A_find = s.find("A")
end_Z_find = s.rfind("Z") + 1

print(end_Z_find - first_A_find)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    S = input()

    l = 0
    r = 0
    flag = False
    for i in range(len(S)):
        if not flag and S[i]=='A':
            l = i
            flag = True
        elif S[i]=='Z':
            r = i
    print(r - l + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#53 B
data=list(input())
i=0
j=1
while data[i]!='A':
    i=i+1
while (data[-j]!='Z' and len(data)-j>i):
    j=j+1
print(len(data)-i-j+1)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
left = s.index('A')
right = s.rindex('Z')
print(right-left+1)

Submission status: Accepted

Solution code:
def main():
    s = input()
    start = 200000
    end = 0
    for i in range(len(s)):
        if s[i] == 'A' and start > i:
            start = i
        elif s[i] == 'Z' and end < i:
            end = i
    print(end - start + 1)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    a = len(s); z = 0
    for i, t in enumerate(s):
        if t == 'A':
            a = min(a, i)
        if t == 'Z':
            z = max(z, i)
    ans = z-a+1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()

    idx_a = s.index("A")
    idx_z = -1

    for i, char in enumerate(s):
        if char == "Z":
            idx_z = i

    print(idx_z - idx_a + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
l = list(sys.stdin.readline().rstrip("\n"))
a = 10000000
z = 0
for i,s in enumerate(l):
    if s == 'A':
        a = min(a,i)
    if s == 'Z':
        z = i
print(z-a+1)

Submission status: Accepted

Solution code:
import re
s = input()
smax=0
res = re.search(r"A[A-Z]*Z",s)
print(len(res.group()))

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

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

Submission status: Accepted

Solution code:
s = input()

ind_A = 0
while s[ind_A] != 'A':
    ind_A += 1
ind_Z = len(s)
while s[ind_Z - 1] != 'Z':
    ind_Z -= 1

print(ind_Z - ind_A)

Submission status: Accepted

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

print(len(s)-a-b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

start=-1
last=-1

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

for j in reversed(range(0,len(S))):
  if S[j]=="Z":
    last=j
    break

print(last-start+1)

Submission status: Accepted

Solution code:
s = input()

st = len(s)
bk = 0
for i in range(len(s)):
    st = min(i, st) if s[i] == 'A' else st
    bk = max(i, bk) if s[i] == 'Z' else bk

print(bk - st + 1)

Submission status: Accepted

Solution code:
# ABC053
S = input()
a_index = 10**10
z_index = -1
for i in range(len(S)):
    if S[i] == "A":
        a_index = min(a_index, i)
    if S[i] == "Z":
        z_index = max(z_index, i)
print(z_index-a_index+1)

Submission status: Accepted

Solution code:
S = input()
start = S.find('A')
end = S.rfind('Z')
print(len(S[start:end])+1)

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

Submission status: Accepted

Solution code:
s = str(input())
a_index = 0
z_index = 0
for i in range(len(s)):
    if s[i] == 'A':
        a_index = i
        break
for i in range(len(s)):
    if s[i] == 'Z':
        z_index = i

print(z_index - a_index + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = s[::-1]


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

print(end-start)

Submission status: Accepted

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

s = list(input())

tmp_str =""
output=""
start_pos = end_pos = -1


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

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

if end_pos>=0 and start_pos>=0:
    length = end_pos - start_pos + 1
else:
    length = 0

print(length)

Submission status: Accepted

Solution code:
s = list(input())

a_idx = 0
z_idx = len(s) - 1
for i in range(len(s)):
  if s[i] == "A":
    a_idx = i
    break

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

print(z_idx - a_idx + 1)

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    s = input()
    i = s.find("A")
    j = s.rfind("Z")
    print(j - i + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


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


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = []
b = 0

for i in s:
    if b == 1:
        l.append(i)
    if i == 'A' and b == 0:
        l.append(i)
        b = 1

z = [i for i, x in enumerate(l, 1) if x == 'Z']
print(max(z))

Submission status: Accepted

Solution code:
s = input()

A_first_index = s.index('A')
Z_last_index = max([i for i, c in enumerate(s) if c == 'Z'])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

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

print(z - a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
import re
s = str(input())
a = re.findall('A[A-Z]*Z', s)
print(max(map(len, a)))

Submission status: Accepted

Solution code:
s = input()

a = s.index('A')
z = list(reversed(s)).index('Z')

print(len(s)-z-a)

Submission status: Accepted

Solution code:
# B - A to Z String
def main():
    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)-1, 0, -1):
        if s[j] == 'Z':
            end = j
            break
    
    print(end-start+1)


        
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    s = input()
    l = len(s)
    forward = 0
    while s[forward] != "A": forward += 1
    back = -1
    while s[back] != 'Z': back -= 1
    print(l - forward + back + 1)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import re
s = str(input())
a = re.search(r'A[A-Z]*Z', s)
print(len(a.group()))

Submission status: Accepted

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

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

S=list(reversed(s))
for j in range(len(S)):
    if S[j]=="Z":
        z=j
        break

print(len(s)-a-z)

Submission status: Accepted

Solution code:
s=input()
A=[]
B=[]
for i in range(0,len(s)):
    if s[i]=='A':
        a=i
        break
S=list(reversed(s))
for j in range(0,len(S)):
    if S[j]=='Z':
        b=j
        break
print(len(s)-a-b)

Submission status: Accepted

Solution code:
s=input()
l,d=[],[]
c=0
for i in s:
    if(i=='A'):
        l.append(c)
    if(i=='Z'):
        d.append(c)
    c+=1
print(max(d)-min(l)+1)

Submission status: Accepted

Solution code:
S=input()

i=0
A=[]
Z=[]
for s in S:
  if s=="A":
    A.append(i)
  elif s=="Z":
    Z.append(i)
  i=i+1
  
print(max(Z)+1-min(A))

Submission status: Accepted

Solution code:
s=input()
Acnt = 0
Zcnt = len(s)-1
while 1:
    if s[Acnt] == 'A':
        Acnt += 1
        break
    else:
        Acnt += 1
while 1:
    if s[Zcnt] == 'Z':
        Zcnt += 1
        break
    else:
        Zcnt -= 1
print(Zcnt-Acnt+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sample = input()
#new = list(sample)
#if "A" in new:
a_pos = sample.index('A')
#if "Z" in new:
z_pos = sample.rfind('Z')
print(z_pos-a_pos+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
m = re.search('A[A-Z]*Z', input())
print(len(m.group()))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

letter = str(input())
pattern = 'A(.*)Z'
target = re.search(pattern, letter).group()
print(len(target))

Submission status: Accepted

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

print(y-x+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
S = input()
a = S.find('A')
b = S.rfind('Z')
print(b - a + 1)

Submission status: Accepted

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

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 - i + 1)

Submission status: Accepted

Solution code:
s=input()
r_s=s[::-1]
c_a=s.find("A")
c_rz=r_s.find("Z")
c_z=len(s)-1-c_rz

print(c_z-c_a+1)

Submission status: Accepted

Solution code:
s = raw_input()
sinv = s[::-1]
z = len(s) -1 - sinv.find('Z')

print z - s.find('A')+1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B.py

S = str(input())
a_point = []
z_point = []

for i in range(len(S)):
    if S[i] == "A":
        a_point.append(i)
    if S[i] == "Z":
        z_point.append(i)

print(max(z_point)-min(a_point)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
i, j = 0, len(s)-1
while(1):
    if s[i] == "A":
        start = i
        break
    i += 1
while(1):
    if s[j] == "Z":
        end = j + 1
        break
    j -= 1
print(end - start)

Submission status: Accepted

Solution code:
s = input()
minA = 200000
maxZ = 0
for i in range(len(s)):
    if s[i] == "A":
        if i < minA:
            minA = i
    elif s[i] == "Z":
        if maxZ < i:
            maxZ = i

print(maxZ - minA + 1)

Submission status: Accepted

Solution code:
#B - A to Z String
s = input()

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

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

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:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()

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

if __name__ == "__main__":
    resolve()

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:
string = input()
index_of_A = string.index("A")
index_of_Z = string.rfind("Z")

print(index_of_Z - index_of_A + 1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(z-a+1)

Submission status: Accepted

Solution code:

s=list(str(input()))

nax=len(s)
first=0
last=nax
for i in range(nax):
    if s[i]=='A':
        first=i
        break
for i in range(nax):
    if s[nax-1-i]=='Z':
        last=nax-i-1
        break

print(last-first+1)

Submission status: Accepted

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


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)


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


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

Submission status: Accepted

Solution code:
s = input()
i, j = 0, len(s)-1
while(1):
    if s[i] == "A":
        start = i
        break
    i += 1
while(1):
    if s[j] == "Z":
        end = j + 1
        break
    j -= 1
print(end - start)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
a = []
z = []
for i, s in enumerate(S):
    if s == "A":
        a.append(i)
    elif s == "Z":
        z.append(i)
print(z[-1]-a[0]+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
start = s.index('A')
end = s.rindex('Z')

print(end - start + 1)

Submission status: Accepted

Solution code:
S = input()

N = len(S)
Aflag = -1
Zflag = 0
for i in range(N):
    if Aflag == -1 and S[i] == 'A':
        Aflag = i
    elif S[i] == 'Z':
        Zflag = i

print(Zflag-Aflag+1)

Submission status: Accepted

Solution code:
if __name__ =='__main__':
    S = input()
    st = 0
    ed = 0
    cnt = 0
    flag = True
    for i, s in enumerate(S):
        if s=='A' and flag:
            st = i
            flag = False
        if s=='Z':
            ed = i
            cnt = max(cnt, ed-st)
    
    print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
a = N.find("A")
z = N.rfind("Z")
print(z - 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()

A=int(s.find("A"))
Z=int(s.rfind("Z"))

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

	n = len(s)

	start = -1
	end = n

	start = s.index("A")
	end = s.rindex("Z")
	
	print(end - start + 1)


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
def main():
	s = input()

	n = len(s)

	start = -1
	end = n

	for i in range(0, n, 1):
		if s[i] == "A":
			start = i
			break

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


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
start = 0
end = 0
#for i in range(len(s)):
#    if s[i]=='A' and start==0:
#        start = i
#    if s[-(i+1)]=='Z' and end==0:
#        end = len(s)-i
#    if start != 0 and end != 0:
#        break
for i in range(len(s)):
    if s[i]=='A':
        start = i
        break
for i in range(len(s)):
    if s[i]=='Z':
        end = i
print(end-start+1)

Submission status: Accepted

Solution code:
s = input()


start = []
finish = []

for i in range(len(s)):
    if s[i] == "A":
        start.append(i)
    elif s[i] == "Z":
        finish.append(i)
    else:
        pass

ans = finish[-1] - start[0] +1
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

count1 = 0
count2 = 0

for i in range(200000):
    if S[i] == "A":
        count1 = i
        break

for i in range(1, 200000 + 1):
    if S[-i] == "Z":
        count2 = i
        break

ans = len(S) - (count1 + count2) + 1
print(ans)

Submission status: Accepted

Solution code:
s = str(input())

for i in s:
    if i == 'A':
        x = s.index(i)
        break
for h in range(len(s)-1,-1,-1):
    if s[h] == 'Z':
        y = h
        break
print(y-x+1)

Submission status: Accepted

Solution code:
s = input()
temp = 10**9
x = []
y = []
for i in range(len(s)):
	if s[i] =="A":
		x.append(i)
	elif s[i]=="Z":
		y.append(i)

mx = min(x)
mz = max(y)


print((mz-mx)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
x=0
y=0
j=0
for i in range(len(s)):
  if j==0 and s[i]=="A":
    j+=1
    x=i
  elif j==1 and s[i]=="Z":
    y=i
print(y-x+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 = input().strip()
a = 10**9
z = 0
for i, s in enumerate(S):
    if s == "A":
        a = min(i, a)
    if s == "Z":
        z = max(i, z)
print(z-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

ans = 0
flag = 0
a = 0

for i in range(len(s)):
    if flag != 1:
        if s[i] == "A":
            flag = 1
            a = i
    elif s[i] == "Z":
        ans = i-a+1

print(ans)

Submission status: Accepted

Solution code:
s= input().strip()
l=len(s)
a=[]
z=[]
for i in range(l):
    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 = 0
Z = 0

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

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
f = 0
b = 0

for i in range(N):
    if 'A' == S[i]:
        break
    else:
        f += 1
for i in range(1,N + 1):
    if 'Z' == S[-i]:
        break
    else:
        b += 1
b = N - b

ans = b - f
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
N=list(str(N))
le=-1
ri=-1
for i in range(len(N)):
  if N[i]=="A":
    le=i
    break
for k in range(len(N)):
  if N[k]=="Z":
    ri=k
print(ri-le+1)

Submission status: Accepted

Solution code:
from collections import deque
s = deque(list(input()))
while True:
  if s.popleft()=="A":
    break
while True:
  if s.pop()=="Z":
    break
print(len(s)+2)

Submission status: Accepted

Solution code:
s = input()

a_i = s.index('A')
s1 = s[::-1]
z_i = s1.index('Z')

print((len(s)-z_i)-a_i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

s = input()

a = 500000000000
z = -1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

st = 0
en = 0

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

for i in range(len(S)):
    if S[i] == "Z":
        en = i

print(en - st + 1)

Submission status: Accepted

Solution code:
s = input()
l = -1
r = 0
for i, si in enumerate(s):
    if si == 'Z':
        r = i
    elif si == 'A' and l == -1:
        l = i
print(r-l+1)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

a_index = INF
b_index = 0
for i, s in enumerate(S):
    if a_index == INF and s == "A":
        a_index = i
    if s == "Z":
        b_index = i

ans = b_index - a_index + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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