AlgoUniversity
  • Go Back
Discussion
Painting Wall :

Author

Akshay Sharma

Difficulty Level : Medium

Submissions : 552

Asked In : Uber

Marks :100

: 7 | : 6

Bob is painting a wall. The wall contains N Sections and he has already painted some sections of the wall randomly.

The wall consists of a string of length N containing lower-case alphabets 'a' to 'z' denoting the color of the section. in 1 operation. Bob can paint a single section of the wall to any new colour.

He is now tired and does not want to do more than k operations. So, he decides to create a continuous segment of the wall which is completely the same colour (a range [i, j] where all wallſk] are equal, i <= K <= 1) What is the maximum length of such a segment he can Create?

Input

The first line of input contains a string s of size N ($$$1 \le N \le 10^5$$$)

The next line of input contains an integer k ($$$0 \le k \le 10^5 $$$)

Output

For each test case print What is the maximum length of such a segment, he can Create?

Example

Input
abaab 1
Output
4

Note

Example : Wall="abaab" and k=1

Bob can paint the 2nd to 'a' so now the maximum segment he can paint is : 4

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.