atcoder#ABC300F. [ABC300F] More Holidays

[ABC300F] More Holidays

Score : 500500 points

Problem Statement

You are given a string SS of length NN consisting of o and x, and integers MM and KK. SS is guaranteed to contain at least one x.

Let TT be the string of length NMNM obtained by concatenating MM copies of SS. Consider replacing exactly KK x's in TT with o. Your objective is to have as long a contiguous substring consisting of o as possible in the resulting TT. Find the maximum length of a contiguous substring consisting of o that you can obtain.

Constraints

  • NN, MM, and KK are integers.
  • 1N3×1051 \le N \le 3 \times 10^5
  • 1M1091 \le M \le 10^9
  • 1Kx1 \le K \le x, where xx is the number of x's in the string TT.
  • SS is a string of length NN consisting of o and x.
  • SS has at least one x.

Input

The input is given from Standard Input in the following format:

NN MM KK

SS

Output

Print the answer as an integer.

10 1 2
ooxxooooox
9

S=S= ooxxooooox and T=T= ooxxooooox. Replacing x at the third and fourth characters with o makes T=T= ooooooooox. Now we have a length-99 contiguous substring consisting of o, which is the longest possible.

5 3 4
oxxox
8

S=S= oxxox and T=T= oxxoxoxxoxoxxox. Replacing x at the 5,7,85,7,8 and 1010-th characters with o makes T=T= oxxooooooooxxox. Now we have a length-88 contiguous substring consisting of o, which is the longest possible.

30 1000000000 9982443530
oxoxooxoxoxooxoxooxxxoxxxooxox
19964887064