AlgoUniversity
  • Go Back
Discussion
Special Substrings :

Author

Gurankit Pal Singh

Difficulty Level : Hard

Submissions : 453

Asked In : Flipkart

Marks :10

: 0 | : 1

You are given a string $$$drawString$$$, $$$numTickets$$$ ticket strings, and an integer $$$tolerance$$$,

You can change each ticket by the following ways:

  • Change character 'o' to character 'a' and vice versa in the ticket any number of times.
  • Change character 't' to character 'l' and vice versa in the ticket any number of times.
  • Erase a character from anywhere in the ticket at most one time.

A ticket is special substring if you can ignore at most $$$tolerance$$$ amount of characters from the $$$drawString$$$ to get a match with the ticket string.

You have to count the number of tickets which are special substring of $$$drawString$$$.

Input

The first line contains an integer $$$numTickets, (0 \le numtickets \le 1000)$$$

The next $$$numtickets$$$ lines contains a string, representing $$$ticket_{i}, (0 \le |ticket_{i}| \le 200$$$

The next line contains a string $$$drawString, (0 \le |drawString| \le 200$$$

The next line contains an integer $$$tolerance, (0 \le tolerance \le 1000)$$$

Output

Print an integer representing the number of tickets which are special substrings.

Examples

Input
3
abcde
aoc
actld
aabacd
1
Output
2
Input
6
abrrra
abra
codabro
cadabrott
caddbrott
obradb
abracadabral
3
Output
4

Note

In the first sample case:

  • For the first ticket 'abcde' - delete 'e' from the ticket, and delete 'a' from the $$$drawString$$$, so the new ticket 'abcd' is a substring of the new $$$drawString$$$.
  • For the second ticket 'aoc' - change 'o' to 'a' and delete 'b' from the $$$drawString$$$. So, the new ticket is the substring of the new $$$drawString$$$.
  • For the third ticket, there is no way to get the ticket as the substring of the $$$drawString$$$.

So, the answer is 2.

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.