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-----
QWERTYASDFZXCV

-----Sample Output-----
5

By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.
[{"code": "s = input()\nfirst_a_index = s.index('A')\nlast_z_index = len(s) - list(reversed(s)).index('Z')\nprint(last_z_index - first_a_index)", "passed": true, "time": 0.29, "memory": 14280.0, "status": "done"}, {"code": "s = input()\nstart = len(s)\nend = 0\nans = 0\n\nfor i in range(len(s)):\n    if s[i] == 'A':\n        start = min(start , i)\n    if s[i] == 'Z':\n        end = max(end, i)\n    ans = end - start + 1\nprint(ans)", "passed": true, "time": 0.18, "memory": 14256.0, "status": "done"}, {"code": "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\n# mod = 10**9 + 7\n#mod = 9982443453\nmod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n  return list(map(int,readline().split()))\ndef readTuples():\n    return tuple(map(int,readline().split()))\ndef I():\n    return int(readline())\ns = input()\nA_idx = s.index('A')\nZ_idx = s[::-1].index('Z')\nln = len(s)\nprint((ln - Z_idx - A_idx))\n", "passed": true, "time": 0.15, "memory": 14248.0, "status": "done"}, {"code": "s = input()\nst = en = 0\nfor i in range(len(s)):\n    if s[i] == \"A\":\n        st = i\n        break\nfor i in range(1,len(s)):\n    if s[-i] == \"Z\":\n        en = len(s) - i + 1\n        break\nprint(en-st)", "passed": true, "time": 0.24, "memory": 14052.0, "status": "done"}, {"code": "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nt = si()\nn = len(t)\nfor s in range(n):\n    if t[s] == 'A':\n        break\n\nfor e in range(n - 1, -1, -1):\n    if t[e] == 'Z':\n        break\n\nprint(e - s + 1)", "passed": true, "time": 0.33, "memory": 14172.0, "status": "done"}, {"code": "s=input()\nS=len(s)\nmi=[]\nma=[]\nfor i in range(S):\n    if s[i]=='A':\n        mi.append(i)\n    elif s[i]=='Z':\n        ma.append(i)\nprint(max(ma)-min(mi)+1)", "passed": true, "time": 0.25, "memory": 14264.0, "status": "done"}, {"code": "import sys\n\nmin_a_index, max_z_index = sys.maxsize, 0\n\nfor index, c in enumerate(list(input())):\n    if c == \"A\" and index < min_a_index:\n        min_a_index = index\n    if c == \"Z\" and index > max_z_index:\n        max_z_index = index\n\nprint((max_z_index - min_a_index + 1))\n", "passed": true, "time": 0.21, "memory": 14092.0, "status": "done"}, {"code": "s = input()\nprint(s.rfind('Z')-s.find('A')+1)", "passed": true, "time": 0.19, "memory": 14076.0, "status": "done"}, {"code": "s = input()\na = len(s)\nz = 0\nfor i in range(len(s)):\n  if s[i] == \"A\":\n    a = min(a,i)\n  if s[i] == \"Z\":\n    z = max(z,i)\n\nprint(z-a+1)", "passed": true, "time": 0.18, "memory": 14284.0, "status": "done"}, {"code": "s=input()\nprint((len(s)-s[::-1].index('Z'))-s.index('A'))", "passed": true, "time": 0.28, "memory": 14164.0, "status": "done"}, {"code": "s = input()\na = len(s)\nz = 0\nfor i,e in enumerate(reversed(s)):\n  if e == \"A\":\n    a = len(s) - i -1 \nfor i,e in enumerate(s):\n  if e == \"Z\":\n    z = i\n\nprint(z-a+1)", "passed": true, "time": 0.26, "memory": 14280.0, "status": "done"}, {"code": "s = input()\n\nfirst_index = s.index('A', 0)\nlast_index = 0\n\nfor i in range(1, len(s)):\n    if s[-i] == 'Z':\n        last_index = len(s) - i\n        break\n\nprint(last_index - first_index + 1)", "passed": true, "time": 0.14, "memory": 14056.0, "status": "done"}, {"code": "import math\n# s=int(input())\nb=input()\nc=[]\nfor i in b:\n    c.append(i)\n#a = list(map(int,input().split()))\n#b = list(map(int,input().split()))\n\na1=c[c.index(\"A\"):]\na2=[i for i, x in enumerate(a1) if x==\"Z\"]\nprint(len(a1[:a2[-1]+1]))", "passed": true, "time": 0.23, "memory": 14164.0, "status": "done"}, {"code": "a=input()\nfor i in range(len(a)):\n    if(a[i]=='A'):\n        b=i\n        break\nfor j in range(len(a)-1,-1,-1):\n    if(a[j]=='Z'):\n        c=j\n        break\nprint((c-b+1))\n", "passed": true, "time": 0.23, "memory": 14188.0, "status": "done"}, {"code": "s = list(input())\n\nfor i,j in enumerate(s):\n    if j == 'A':\n        a = i\n        break\nfor i,j in enumerate(s):\n    if j == 'Z':\n        z = i\nprint(z-a+1)", "passed": true, "time": 0.17, "memory": 14100.0, "status": "done"}, {"code": "s=input()\nn=len(s)\nt=[]\nfor i in range(n):\n  t.append(s[n-1-i])\na=s.index('A')\nz=t.index('Z')\nprint(n-z-a)", "passed": true, "time": 0.21, "memory": 14024.0, "status": "done"}, {"code": "n = input()\na = n.find(\"A\")\nz = n.rfind(\"Z\")\nprint(z-a+1)", "passed": true, "time": 0.23, "memory": 14232.0, "status": "done"}, {"code": "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n    S = input()\n    search_string=['A','Z']\n    position=[]\n\n#A\u3092\u63a2\u3059\n    for i,s in enumerate(S):\n        if s==search_string[0]:\n            position.append(i)\n            break\n\n#Z\u3092\u63a2\u3059\n    for r_i,r_s in enumerate(reversed(S)):\n        if r_s==search_string[1]:\n            position.append(len(S)-r_i)\n            break\n\n    print(position[1]-position[0])\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.21, "memory": 14232.0, "status": "done"}, {"code": "S=input()\nleft=0\nwhile S[left]!='A':\n    left+=1\nright=len(S)-1\nwhile S[right]!='Z':\n    right-=1\nprint((right-left+1))\n", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "s=input()\ni = s.index(\"A\")\nj = len(s)-s[::-1].index(\"Z\")\nprint(len(s[i:j]))", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "def resolve():\n    \"\"\"\u300cA*Z\u300d\u3068\u3044\u3046\u6587\u5b57\u5217\u3067\u6700\u9577\u306e\u9577\u3055\u3092\u51fa\u529b\u3059\u308b\n    = \u4e00\u756a\u5de6\u306eA\u3068\u4e00\u756a\u53f3\u306eZ\u3067\u3067\u304d\u308b\u6587\u5b57\u5217\n    \"\"\"\n    s = input()\n    start_index = s.index(\"A\")\n    end_index = s.rindex(\"Z\")\n    output = end_index - start_index + 1\n    print(output)\n\nresolve()", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "s = input()\nfor i in range(len(s)):\n    if s[i] == 'A':\n        p = i\n        break\nfor i in range(1,len(s)+1):\n    if s[-i] == 'Z':\n        q = i-1\n        break\nprint(len(s) -(p+q))", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "s = input()\nsta = []\nfin = []\nfor i in range(len(s)):\n    if s[i] == 'A':\n        sta.append(i)\n    elif s[i] == 'Z':\n        fin.append(i)\nprint(max(fin)-min(sta)+1)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "s = input()\n\nfor i, x in enumerate(s):\n    if x == \"A\":\n        break\n\nfor j, x in enumerate(s[::-1]):\n    if x == \"Z\":\n        break\n\nprint((len(s) - i - j))\n", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "s=list(input())\ns_inv=list(reversed(s))\na=s.index('A')\nz=s_inv.index('Z')\nprint(len(s)-a-z)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "s = str(input())\nstrFindA = ''\nstrFindZ = ''\n\nfor i in range(len(s)):\n  if s[i] == \"A\":\n    strFindA = s[i:]\n    break\n\nfor i in reversed(range(len(strFindA))):\n  if strFindA[i] == \"Z\":\n    strFindZ = strFindA[:i+1]\n    break\n\nprint(len(strFindZ))", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "def main():\n    s = input()\n    start = 200000\n    end = 0\n    for i in range(len(s)):\n        if s[i] == 'A' and start > i:\n            start = i\n        elif s[i] == 'Z' and end < i:\n            end = i\n    print(end - start + 1)\n\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "s = input()\n\nfirst = s.index('A')\nend = s.rindex('Z')\n\nans = end - first + 1\nprint(ans)", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "s = input()\n\na = s.index('A')\nz = len(s) - s[::-1].index('Z')\nprint(z - a)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "s = input()\nn = len(s)\na = 0\nz = n - 1\n\nfor i in range(n):\n    if s[i] == \"A\":\n        a = i\n        break\n\nfor i in range(n):\n    if s[i] == \"Z\":\n        z = i\n\nprint((z - a + 1))\n", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "s = input()\n\nf = s.find('A')\nl = len(s) - s[::-1].find('Z')\nprint(l - f)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\n\ndef read():\n    s = input().strip()\n    return s,\n\n\ndef solve(s):\n    a, z = 0, len(s)-1\n    while s[a] != \"A\":\n        a += 1\n    while s[z] != \"Z\":\n        z -= 1\n    return z-a+1\n\n\ndef __starting_point():\n    inputs = read()\n    print((solve(*inputs)))\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "S = input()\nans = S.rfind(\"Z\") - S.find(\"A\") + 1\nprint(ans)", "passed": true, "time": 0.15, "memory": 14076.0, "status": "done"}, {"code": "s = input()\n\ndef first_A(s):\n  for i in range(len(s)):\n    if s[i] == \"A\":\n      return i\n    \ndef last_Z(s):\n  for i in range(len(s)):\n    if s[-(i+1)] == \"Z\":\n      return -(i+1)+len(s)\n    \nprint(last_Z(s) - first_A(s) + 1)", "passed": true, "time": 0.15, "memory": 14284.0, "status": "done"}, {"code": "s = input()\nsr = s[::-1]\n\nfor i in range(len(s)):\n  if s[i] == \"A\" :\n    st = i+1\n    break\n\nfor i in range(len(s)):\n  if sr[i] == \"Z\":\n    en = len(s)-i\n    break\n\nprint(en - st + 1)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "a = input()\nfor i in range(len(a)):\n    if a[i] == \"A\":\n        b = i\n        break\nfor j in range(len(a)):\n    if a[j] == \"Z\":\n        c = j\nprint((c-b+1))\n", "passed": true, "time": 0.42, "memory": 14092.0, "status": "done"}, {"code": "s = input()\nstart = s.find('A')\nend = s.rfind('Z',start)\nprint(end - start + 1)", "passed": true, "time": 0.19, "memory": 14096.0, "status": "done"}, {"code": "s=input()\nb=s.index(\"A\")\na=[i for i, x in enumerate(s) if x == 'Z']\nprint(a[-1]-b+1)", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "s = input()\na_number = 0\nz_number = 0\n\nfor i in range(len(s)):\n    if s[i] == 'A':\n        a_number = i\n        break\n\nfor j in reversed(range(len(s))):\n    if s[j] == 'Z':\n        z_number = j\n        break\n\nprint(z_number - a_number + 1)", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "S = input()\nans = -S[::-1].find(\"Z\") - S.find(\"A\")+len(S)\nprint(ans)\n", "passed": true, "time": 0.21, "memory": 14088.0, "status": "done"}, {"code": "a=input()\nprint(a.rindex(\"Z\")-a.index(\"A\")+1)", "passed": true, "time": 0.23, "memory": 14192.0, "status": "done"}, {"code": "s = input()\nprint(s.rfind(\"Z\")-s.find(\"A\")+1)", "passed": true, "time": 0.26, "memory": 14088.0, "status": "done"}, {"code": "retu = input()\nkari = 0\nflag = False\nfor i in range(len(retu)):\n    if flag:\n        kari += 1\n        if retu [i] == 'Z':\n            an = kari\n    elif retu[i] == 'A':\n        flag = True\n        kari += 1\nprint(an)", "passed": true, "time": 0.21, "memory": 14184.0, "status": "done"}, {"code": "s=list(input())\nfor i in range(len(s)):\n  if s[i]==\"A\":\n    start=i\n    break\nfor j in reversed(range(0,len(s))):\n  if s[j]==\"Z\":\n    last=j\n    break\nprint(last-start+1)", "passed": true, "time": 0.18, "memory": 14164.0, "status": "done"}, {"code": "#53 B\ndata=list(input())\ni=0\nj=1\nwhile data[i]!='A':\n    i=i+1\nwhile (data[-j]!='Z' and len(data)-j>i):\n    j=j+1\nprint(len(data)-i-j+1)", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "s=input()\nx=s.find('A')\ns2=s[x:]\ny=s.rfind('Z')\nprint(y-x+1)", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "S = input()\ns_list = []\nfor n in S:\n    s_list.append(n)\n\na = (s_list.index(\"A\"))+1\n\ns_list.reverse()\nz = (-(s_list.index(\"Z\")+1))\n\nprint(len(S[a:z])+2)", "passed": true, "time": 0.15, "memory": 14032.0, "status": "done"}, {"code": "s = input()\nsize = len(s)\nfor i in range(size):\n    if s[i] == 'A':\n        head = i\n        for j in range(size):\n            if s[-1-j] == 'Z':\n                tail = j \n                break\n        break \nprint(size-head-tail)", "passed": true, "time": 0.23, "memory": 14300.0, "status": "done"}, {"code": "s = list(input())\nfor i in range(len(s)):\n    if s[i] == \"A\":\n        a = i\n        break\nfor j in range(len(s)-1, 0, -1):\n    if s[j] == \"Z\":\n        b = j\n        break\nprint(b-a+1)", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "s = input()\nprint((s.rfind('Z') - s.find('A') + 1))\n", "passed": true, "time": 0.19, "memory": 14320.0, "status": "done"}, {"code": "s = input()\n\nl = s.index('A')\nr = len(s)-s[::-1].index('Z')\nprint((len(s[l:r])))\n", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "S = input()\nN = len(S)\na = 1\nz = 1\nfor i in range(N):\n    if S[i] == \"A\":\n        break\n    else:\n        a += 1\n\nfor j in range(1, N+1):\n    if S[-j] == \"Z\":\n        break\n    else:\n        z += 1\nans = N - a - z + 2\nprint(ans)", "passed": true, "time": 0.14, "memory": 14352.0, "status": "done"}, {"code": "def main():\n    s = input()\n    a = len(s); z = 0\n    for i, t in enumerate(s):\n        if t == 'A':\n            a = min(a, i)\n        if t == 'Z':\n            z = max(z, i)\n    ans = z-a+1\n    print(ans)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "s = input()\n\nind_A = 0\nwhile s[ind_A] != 'A':\n    ind_A += 1\nind_Z = len(s)\nwhile s[ind_Z - 1] != 'Z':\n    ind_Z -= 1\n\nprint(ind_Z - ind_A)", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "a=input()\nb=a[::-1]\np=0\n\nfor i in range(len(a)):\n  if a[0] !='A':\n    a=a[1:]\n  else:\n    break\n    \nfor i in range(len(a)):\n  if a[-1] !='Z':\n    a=a[:-1]\n  else:\n    break\n    \n    \nprint(len(a))", "passed": true, "time": 0.14, "memory": 14024.0, "status": "done"}, {"code": "s = input()\n\nprint((s.rindex('Z') - s.index('A') + 1))\n", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "s = input()\na_idx = None\nfor i, c in enumerate(list(s)):\n    if c == 'A':\n        a_idx = i\n        break\nz_idx = None\nfor i, c in enumerate(reversed(list(s))):\n    if c == 'Z':\n        z_idx = len(s) -i\n        break\nprint(len(s[a_idx:z_idx]))", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "import re\ns = input()\nsmax=0\nres = re.search(r\"A[A-Z]*Z\",s)\nprint(len(res.group()))", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "S = input()\n\nleft = -1\n\nfor i,s in enumerate(S):\n    if s == 'A':\n        left = i\n        break\n\nright = len(S)+1\nfor i in range(len(S)-1, -1, -1):\n    if S[i] == 'Z':\n        right = i\n        break\n\nif left < right:\n    print(right-left+1)", "passed": true, "time": 0.24, "memory": 14132.0, "status": "done"}, {"code": "s = input()\nstart = 0\ngoal = 1\nwhile s[start] != \"A\":\n  start += 1\nwhile s[-goal] != \"Z\":\n  goal += 1\nprint(len(s)-goal-start+1)", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "s = input()\nx = s.find('A')\ny = s.rfind('Z')\nprint(y-x+1)", "passed": true, "time": 0.86, "memory": 14092.0, "status": "done"}, {"code": "s = input()\nprint(s.rfind('Z')-s.find('A')+1)", "passed": true, "time": 0.22, "memory": 14092.0, "status": "done"}, {"code": "s = input()\nstart = s.find('A')\nend = s.rfind('Z',start)\nprint(end - start + 1)", "passed": true, "time": 0.21, "memory": 14080.0, "status": "done"}, {"code": "s = input()\na = 0\nz = 0\nfor i in range(len(s)):\n    if s[i]==\"A\":\n        a = i \n        break\nfor i in range(len(s)-1,-1,-1):\n    if s[i]==\"Z\":\n        z = i \n        break \nprint(z-a+1)", "passed": true, "time": 0.27, "memory": 14320.0, "status": "done"}, {"code": "s=input()\nprint((s.rfind('Z')-s.find('A')+1))\n", "passed": true, "time": 0.21, "memory": 14304.0, "status": "done"}, {"code": "s = input()\nlengs = s.rfind(\"Z\") - s.find(\"A\")\nprint(lengs+1)", "passed": true, "time": 0.21, "memory": 14096.0, "status": "done"}, {"code": "s = list(input())\ns_inv = list(reversed(s))\na = s.index('A')\nb = s_inv.index('Z')\nprint(len(s)-a-b)", "passed": true, "time": 0.27, "memory": 14244.0, "status": "done"}, {"code": "s = input()\n\na_index = s.find('A')\nz_index = s.rfind('Z')\n  \nprint(z_index - a_index + 1)", "passed": true, "time": 0.21, "memory": 14184.0, "status": "done"}, {"code": "s = input()\n\nfirst_A_find = s.find(\"A\")\nend_Z_find = s.rfind(\"Z\") + 1\n\nprint(end_Z_find - first_A_find)", "passed": true, "time": 0.21, "memory": 14212.0, "status": "done"}, {"code": "s = input()\nprint(s.rfind('Z') - s.find('A') + 1)", "passed": true, "time": 0.2, "memory": 14300.0, "status": "done"}, {"code": "s = input()\na, z = len(s), 0\nfor i in range(len(s)):\n    if s[i] == 'A':\n        a = min(i, a)\n    elif s[i] == 'Z':\n        z = max(i, z)\n\nprint(z-a+1)", "passed": true, "time": 0.2, "memory": 14208.0, "status": "done"}, {"code": "s = input()\na = s.find('A')\nz = s.rfind('Z')\nprint(z - a + 1)", "passed": true, "time": 0.2, "memory": 14192.0, "status": "done"}, {"code": "s = input()\nprint(s.rfind(\"Z\")-s.find(\"A\")+1)", "passed": true, "time": 0.24, "memory": 14188.0, "status": "done"}, {"code": "s=input()\nprint(s.rfind(\"Z\")-s.find(\"A\")+1)", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "s=list(input())\n\nfor i in range(len(s)):\n    if(s[i]=='A'):\n        a=i\n        break\n\nfor i in range(len(s)-1,-1,-1):\n    if(s[i]=='Z'):\n        z=i\n        break\n\nprint(z-a+1)", "passed": true, "time": 0.2, "memory": 14208.0, "status": "done"}, {"code": "s = list(input())\nt = s.copy()\nt.reverse()\nprint(len(s)-t.index(\"Z\")-s.index(\"A\"))", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "s = input()\n\na = s.index('A')\nz = len(s) - s[-1::-1].index('Z')\nprint(z - a)", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "s = input()\nbegin = 0\nend = 0\nfor i in range(len(s)):\n    if s[i]=='A':\n        begin = i\n        break\nfor i in range(len(s)-1,-1,-1):\n    if s[i]=='Z':\n        end = i\n        break\nprint(end-begin+1)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "def answer(s: str) -> int:\n    return s.rfind('Z') - s.find('A') + 1\n\n\ndef main():\n    s = input()\n    print((answer(s)))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.2, "memory": 14212.0, "status": "done"}, {"code": "a=input()\nfor i in range(len(a)):\n  if a[i]==\"A\":\n    b=i\n    break\nfor k in range(len(a)):\n  if a[-k-1]==\"Z\":\n    c=k\n    break\nprint(len(a)-c-b)", "passed": true, "time": 0.2, "memory": 14120.0, "status": "done"}, {"code": "s = input()\nst = s.find(\"A\")\nfor i in range(len(s)):\n  n = len(s)-i-1\n  t = s[n]\n  if t == \"Z\":\n    en = n\n    break\nprint((en - st + 1))\n", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "s = input()\n\nmax_len = 0\npast = -1\nfor i in range(len(s)):\n    if s[i] == 'A' and past == -1:\n        past = i\n        continue\n    if s[i] == 'Z':\n        max_len = max(max_len, i - past + 1)\n\nprint(max_len)\n", "passed": true, "time": 0.2, "memory": 14144.0, "status": "done"}, {"code": "s = input()\nn = len(s)\nfirst, last = 0,0\n\nfor i in range(n):\n  b,f = i+1, n-i\n  if s[-1-i] == 'A':\n    first = f\n  if s[i] == 'Z':\n    last = b\n\n# print(first, last)\nprint((last - first+1))\n", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "s = input()\n\nfor i in range(len(s)):\n   if s[i] == 'A':\n      start = i\n      break\n\nfor i in range(1, len(s) + 1):\n   if s[(-1) * i] == 'Z':\n      end = i\n      break\n\nprint(len(s) - end - start + 1)", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "s = list(input())\n\nwhile s[0] != 'A' or s[-1] != 'Z':\n    if s[0] == 'A':\n        s.pop()\n    elif s[-1] == 'Z':\n        s.pop(0)\n    else:\n        s.pop(0)\n        s.pop()\n\nprint(len(s))", "passed": true, "time": 0.14, "memory": 14248.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(s: str):\n    A = min((i for i, c in enumerate(s) if c == \"A\"), default=len(s))\n    Z = max((i for i, c in enumerate(s) if c == \"Z\"), default=0)\n    return max(0, Z - A + 1)\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n    def iterate_tokens():\n        for line in sys.stdin:\n            for word in line.split():\n                yield word\n    tokens = iterate_tokens()\n    s = next(tokens)  # type: str\n    print((solve(s)))\n\ndef test():\n    import doctest\n    doctest.testmod()\n\ndef __starting_point():\n    #test()\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "s = input()\na = s.find('A')\nz =s.rfind('Z')\nprint(z-a+1)", "passed": true, "time": 0.14, "memory": 14056.0, "status": "done"}, {"code": "s = input()\nans = [\"\",\"\"]\nfor i in range(len(s)):\n    if s[i] == \"A\" and ans[0] == \"\":\n        ans[0] = i+1\n    if ans[0] != \"\" and s[i]==\"Z\":\n        ans[1] = i+1\nprint(ans[1]-ans[0]+1)", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "s=str(input())\nfor i in range(len(s)):\n  if s[i]==\"A\":\n    a=i\n    break\nt=s[::-1]\nfor j in range(len(s)):\n  if t[j]==\"Z\":\n    b=j\n    break\n\nprint(len(s)-a-b)", "passed": true, "time": 0.14, "memory": 14380.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(s: str):\n    return s.rfind(\"Z\") - s.find(\"A\") + 1\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n    def iterate_tokens():\n        for line in sys.stdin:\n            for word in line.split():\n                yield word\n    tokens = iterate_tokens()\n    s = next(tokens)  # type: str\n    print((solve(s)))\n\ndef test():\n    import doctest\n    doctest.testmod()\n\ndef __starting_point():\n    #test()\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "s = input()\n\na = s.find('A')\nb = s.rfind('Z')\n\nprint(b - a + 1)", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "s = input()\nfront = s.find(\"A\")\nback = s.rfind(\"Z\")\nprint(back+1 - front)", "passed": true, "time": 0.14, "memory": 14012.0, "status": "done"}, {"code": "s = str(input())\na = len(s)\nz = 0\nfor i in range(len(s)):\n    if s[i] == 'A':\n        a = min(a, i)\n    if s[i] == 'Z':\n        z = max(z, i)\n\nprint((z - a + 1))\n\n", "passed": true, "time": 0.2, "memory": 14212.0, "status": "done"}, {"code": "s = input()\n\ni = s.find(\"A\")\nj = s.rfind(\"Z\")\n\nprint(j + 1 - i)", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "s=input()\nfor i in range(len(s)):\n    if s[i]==\"A\":\n        s=s[i:]\n        break\nfor j in range(1,len(s)):\n    if s[-j]==\"Z\":\n        s=s[:-j]+\"Z\"\n        break\nprint(len(s))", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "s = input()\n\nfirst_index = s.index('A', 0)\nlast_index = 0\nfor i, ss in enumerate(s):\n    if ss == 'Z':\n        last_index = i\n\nprint(last_index - first_index + 1)", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "s = input()\nn = len(s)\n\nfor i in range(n-1):\n  if s[i] == \"A\":\n    break\n    \nfor j in range(1,n)[::-1]:\n  if s[j] == \"Z\":\n    break\n    \nprint(len(s[i:j+1]))", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "s = input()\n\nfirst = s.find(\"A\")\nend = s.rfind(\"Z\")\n\nlength = end - first + 1\nprint(length)", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}]