cho.sh
Notes
Loading...

Expandable Beautiful Triangles

Time limit

2s

Memory limit

128 MB

Problem

An N×M rectangle is divided into 1×1 unit squares. Each unit square has one point at its center, and each point is colored one of R (red), G (green), or B (blue).

Choose three distinct points and connect them. The three points may lie on one straight line; such a degenerate shape is still treated as a triangle, with area 0. If the three vertices have three different colors, the triangle is called beautiful.

If two beautiful triangles A and B share two vertices and the area of B is greater than the area of A, then A is an expandable beautiful triangle.

Given the color arrangement of the rectangle, count the number of distinct expandable beautiful triangles.

Input

The first line contains two positive integers N and M. (1 ≤ N, M ≤ 50)

Each of the next N lines contains the color arrangement of one row of the rectangle. Every character is one of R, G, and B.

Output

Print the number of expandable beautiful triangles.