Big Hexagons X26557


Statement
 

pdf   zip

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,YX,Y, 2X,Y1002 \leq X,Y \leq 100. XX is the number of grid points in the first row, and YY is the number of rows. Odd-numbered rows contain XX grid points and even-numbered rows contain X1X-1 grid points.

The following YY 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.

Public test cases
  • Input

    10 9
    . . . . . . . . . .
     . . . . . . . . .
    . . . b a . a . . .
     . b . . b . . a a
    . . . a . . . a . a
     c b . . b . . a a
    c c c b a . a . . .
     c c . . . . . . .
    . . . . . . . . . .
    

    Output

    3
    
  • Information
    Author
    Eryk Kopczynski
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++