Longest X

AtCoder
IDabc229_d
Time2000ms
Memory256MB
Difficulty
Given is a string $S$ consisting of `X` and `.`. You can do the following operation on $S$ between $0$ and $K$ times (inclusive). * Replace a `.` with an `X`. What is the maximum possible number of consecutive `X`s in $S$ after the operations? ## Constraints * $1 \leq |S| \leq 2 \times 10^5$ * Each character of $S$ is `X` or `.`. * $0 \leq K \leq 2 \times 10^5$ * $K$ is an integer. ## Input Input is given from Standard Input in the following format: $S$ $K$ [samples]
Samples
Input #1
XX...X.X.X.
2
Output #1
5

After replacing the `X`s at the $7$\-th and $9$\-th positions with `X`, we have `XX...XXXXX.`, which has five consecutive `X`s at $6$\-th through $10$\-th positions.  
We cannot have six or more consecutive `X`s, so the answer is $5$.
Input #2
XXXX
200000
Output #2
4

It is allowed to do zero operations.
API Response (JSON)
{
  "problem": {
    "name": "Longest X",
    "description": {
      "content": "Given is a string $S$ consisting of `X` and `.`. You can do the following operation on $S$ between $0$ and $K$ times (inclusive). *   Replace a `.` with an `X`. What is the maximum possible number o",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc229_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a string $S$ consisting of `X` and `.`.\nYou can do the following operation on $S$ between $0$ and $K$ times (inclusive).\n\n*   Replace a `.` with an `X`.\n\nWhat is the maximum possible number o...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments