Big Hexagons

Tokens of several colors have been placed on a hex grid.

[image]

Your task is count the number of regular hexagons whose all vertices are
of the same color.

Input

The first line contains two numbers X, Y, 2 ≤ X, Y ≤ 100. X is the
number of grid points in the first row, and Y is the number of rows.
Odd-numbered rows contain X grid points and even-numbered rows contain
X − 1 grid points.

The following Y lines contain a description of a board. A dot denotes an
empty grid points, and colors are denoted by lowercase characters
(’a’-’z’). See the example.

Output

Output the number of regular hexagons.

Problem information

Author: Eryk Kopczynski

Generation: 2026-01-25T14:44:12.323Z

© Jutge.org, 2006–2026.
https://jutge.org
