After the evil Max zapped all of Mr. DeMello's flavour text writing ability, Max has decided running out of problems is getting old.
Max started digging out old Yali training camp problems.
Given that Richard Peng is a facilitator of the NA and China problem trade, Max asks him for help.
With Richard Peng's help, he translated one of their problems and nerfed it to two arbitrary values:
Given an grid of lowercase characters, find the number of distinct subgrids of .
Since this is a Richard problem, Max cannot solve it, so he asks you for help.
Can you solve it for him?
Constraints
For all subtasks:
Subtask 1 [30%]
Subtask 2 [70%]
Input Specification
The first line will contain three integers, , , and , the number of rows in the grid, the number of columns in the grid, and the size of the subgrid.
The next lines will contain space-separated lowercase letters, representing the grid.
Output Specification
Output the number of distinct subgrids.
Sample Input
3 3 2
a b c
d a b
f d a
Sample Output
3
Explanation for Sample Output
There are a total of subgrids of size . Out of these grids, only 3 are distinct (the subgrid from to occurs again at to ).
Comments