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.