After a long day, Adam is on his way home. However, after suffering a sudden bout of amnesia, he has forgotten the name of the street where he lives!
Fortunately, he has a list of racecar
or tacocat
).
Can you help Adam figure out the total number of strings on his list that satisfy these constraints?
Constraints
For all subtasks:
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line will contain the values for
The next
The next
Output Specification
Print out, on a single line, the number of strings that Adam is considering which satisfies the constraints.
Sample Input 1
3 2 8
maineste
aracecar
reeeeeee
3 3
2 8
Sample Output 1
2
Explanation for Sample Output 1
Though all three candidate strings satisfy the first constraint, only the second and third strings satisfy the
Sample Input 2
2 2 3
aaa
aba
1 3
2 3
Sample Output 2
1
Explanation for Sample Output 2
Only the first string satisfies both the string itself being a palindrome and the substring
Comments