#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct P {
	int x, y;

	P(int x, int y) : x(x) , y(y) { }
	P() { this -> x = this -> y = 0; }
};

int main() {
	int W, H; cin >> W >> H;
	int ans = 0;

	bool wall[102][102] = {0};
	for (int y = 1; y <= H; ++y)
		for (int x = 1; x <= W; ++x) {
			int f; cin >> f;
			wall[y][x] = f;
		}

	bool used[102][102] = {0};

	queue<P> que;
	que.push( P(0, 0) );
	while ( !que.empty() ) {
		P p = que.front(); que.pop();

		if (p.x < 0 || p.x >= W+2 || p.y < 0 || p.y >= H+2) continue;
		if (wall[p.y][p.x]) {
			++ans;
			continue;
		}
		if (used[p.y][p.x]) continue;

		used[p.y][p.x] = true;

		if (p.y % 2) {
			que.push( P(p.x,   p.y-1) );
			que.push( P(p.x-1, p.y)   );
			que.push( P(p.x,   p.y+1) );
			que.push( P(p.x+1, p.y+1) );
			que.push( P(p.x+1, p.y)   );
			que.push( P(p.x+1, p.y-1) );
		}
		else {
			que.push( P(p.x-1, p.y-1) );
			que.push( P(p.x-1, p.y)   );
			que.push( P(p.x-1, p.y+1) );
			que.push( P(p.x,   p.y+1) );
			que.push( P(p.x+1, p.y)   );
			que.push( P(p.x,   p.y-1) );
		}
	}

	cout << ans << endl;
}