Beach

Count the hexagon edges that separate land from water, ignoring any edge on the outer border of the map.

Medium4ImplementationMatrixSimulationGeometryInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given a map made of unit regular hexagons. Write a program that computes the length of the beach.

A beach is a hexagon edge with water on one side and land on the other. Each edge has length 1. The area outside the map counts as neither water nor land, so an edge on the border of the map is never a beach.

The map has NN rows, and each row is MM hexagons placed side by side. Counting from the top, every even-numbered row (the 2nd, the 4th, and so on) is shifted half a cell to the right of the row directly above it. The figure below shows the map of the second example, with the beach edges drawn in red.

Input

The first line contains the height NN and the width MM of the map. (1N,M501 \le N, M \le 50)

Each of the next NN lines contains one row of the map as a string of length MM. . is water and # is land.

Output

Print the length of the beach on the first line.