/
Time Limit: 2 sec / Memory Limit: 256 MiB
配点 : 200 点
問題文
すぬけくんは文字列 s の連続した一部分(部分文字列という)を取り出して先頭が A であり末尾が Z であるような文字列を作ることにしました。
すぬけくんが作ることのできる文字列の最大の長さを求めてください。
なお,s には先頭が A であり末尾が Z であるような部分文字列が必ず存在することが保証されます。
制約
- 1 ≦ |s| ≦ 200{,}000
- s は英大文字のみからなる
- s には先頭が
Aであり末尾がZであるような部分文字列が必ず存在する
入力
入力は以下の形式で標準入力から与えられる。
s
出力
答えを出力せよ。
入力例 1
QWERTYASDFZXCV
出力例 1
5
7 文字目から 11 文字目までを取り出して ASDFZ を作ると、先頭が A 末尾が Z であるような文字列を得ることが可能です。
入力例 2
ZABCZ
出力例 2
4
入力例 3
HASFJGHOGAKZZFEGA
出力例 3
12
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
Aand ends withZ.
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