atcoder#ABC229D. [ABC229D] Longest X

[ABC229D] Longest X

Score : 400400 points

Problem Statement

Given is a string SS consisting of X and ..

You can do the following operation on SS between 00 and KK times (inclusive).

  • Replace a . with an X.

What is the maximum possible number of consecutive Xs in SS after the operations?

Constraints

  • 1S2×1051 \leq |S| \leq 2 \times 10^5
  • Each character of SS is X or ..
  • 0K2×1050 \leq K \leq 2 \times 10^5
  • KK is an integer.

Input

Input is given from Standard Input in the following format:

SS

KK

Output

Print the answer.

XX...X.X.X.
2
5

After replacing the Xs at the 77-th and 99-th positions with X, we have XX...XXXXX., which has five consecutive Xs at 66-th through 1010-th positions. We cannot have six or more consecutive Xs, so the answer is 55.

XXXX
200000
4

It is allowed to do zero operations.