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 N rows, and each row is M 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.
