QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#14533. Online Preliminary Contest

Statistiques

Siri is participating in the China Collegiate Programming Contest (CCPC) online preliminary round.

After finishing the easy problem, she went to the restroom. When she returned, she found an extra character matrix on her editor.

This character matrix has $n$ rows, where each row has a length of $m$, and it consists only of lowercase letters.

She intends to choose two consecutive rows and two consecutive columns, such that the intersection of these two rows and two columns forms a $2 \times 2$ submatrix.

She wants to know how many such submatrices $A$ satisfy the condition $A = \begin{bmatrix} c & c \\ p & c \end{bmatrix}$.

Input

The first line contains two integers $n, m$ ($2 \leq n, m \leq 500$), representing the size of the matrix.

The next $n$ lines each contain a string of length $m$, representing the character matrix. The data is guaranteed to contain only lowercase letters.

Output

Output a single integer representing the answer.

Examples

Input 1

3 4
cccc
spcc
ccpc

Output 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.