String Fight
Practice
3.1 (7 votes)
Easy
Problem
81% Success 1599 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Two fighters were fighting in the arena to win the title HEAVY WEIGHT CHAMPIONSHIP and the special guest for the tournament was gennady korotkevich . After seeing for while our guest Mr. gennady got bored and decided to change the competition style, instead of fighting he gave them a string which may contains all integers from 0-9. now he is keen on knowing that how many sub-string that can be created from a given string contains a character c exactly p times.

As one of the fighter is from INDIA , so it becomes our national duty to solve this problem as quickly as possible to help INDIA win world heavy weight championship.

Input

First line contains integer t denoting the number of test cases,

for next 2*t (2 lines for each test case ) ,

the first line contain two integers p and c, second line contain a string.

Output

Output the answer in each line.

Constraints

1<=t<=10

i<=p,|s|<=1000000

0<=c<=9

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
10 votes
Tags:
AlgorithmsString Manipulation
Points:30
22 votes
Tags:
String manipulationString AlgorithmsAlgorithmsString Searching
Points:30
16 votes
Tags:
ApprovedEasyHash MapsKMP AlgorithmOpenString Manipulation
Editorial

No editorial available for this problem.