A to Z String

AtCoder
IDabc053_b
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
Input #1
QWERTYASDFZXCV
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`.
Input #2
ZABCZ
Output #2
4
Input #3
HASFJGHOGAKZZFEGA
Output #3
12
API Response (JSON)
{
  "problem": {
    "name": "A to Z String",
    "description": {
      "content": "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 S",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc053_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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$).\nFind the greatest length of the string S...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments