#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

pair<int, int>getnext(const pair<int, int>&now, const int way) {
	if (now.second % 2) {
		const int dx[] = { -1,0,1,1,1,0 };
		const int dy[] = { 0,1,1,0,-1,-1 };
		return make_pair(now.first + dx[way], now.second + dy[way]);
	}
	else {
		const int dx[] = { -1,-1,0,1,0,-1 };
		const int dy[] = { 0,1,1,0,-1,-1 };
		return make_pair(now.first + dx[way], now.second + dy[way]);
	}
}
int W, H;
int check(const pair<int,int>&p,const vector<vector<int>>&field,const vector<vector<int>>&came) {
	if (p.first < 0 || p.first >= W + 2 || p.second < 0 || p.second >= H + 2)return -1;
	else if (came[p.second][p.first])return -1;
	else if (field[p.second][p.first])return 1;
	else return 0;
}
int main() {cin >> W >> H;
	vector<vector<int>>field(H + 2, vector<int>(W + 2));
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			cin >> field[i][j];
		}
	}
	queue<pair<int, int>>que;
	vector<vector<int>>came(H + 2, vector<int>(W + 2));
	que.push(make_pair(0, 0));
	came[0][0] = true;
	int ans = 0;
	while (!que.empty()) {
		auto p(que.front());
		que.pop();
		for (int way = 0; way < 6; ++way) {
			auto nextp(getnext(p, way));
			int num = check(nextp, field,came);
			if (num == -1)continue;
			else if (num == 0) {
				came[nextp.second][nextp.first] = true;
				que.push(nextp);
			}
			else {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}