LCC/Moose '19 Contest 2 J2 - Characteristic Characters

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Derek really likes string manipulations, but he is having trouble finding the index of a certain character in his string.

He wants to find the N_{th} occurrence of the K_{th} character.

Output the index of that character.

Input Specification

The first line will contain the two integers, N (1 \le N\le 10^5) and K (0 \le K\le 10^5-1).

The second line will contain a string of length \le10^5 lowercase, latin characters.

It is guaranteed that the K_{th} character will appear at least N times.

Output Specification

On the first line, output the zero-based index of the N_{th} occurrence of the K_{th} character in the string.

Sample Input 1

1 2
abca

Sample Output 1

2

Sample Input 2

5 1
ababbbbbbbbbb

Sample Output 2

6

Comments

There are no comments at the moment.