#include<iostream>
using namespace std;

int W, H;
bool Buildings[102][102] = {0};
bool visible[102][102] = { false };

void visibilityDiffusion(int w, int h){
	if (w == 0 || h == 0 || w == W + 1 || h == H + 1) return;
	if (visible[w][h]) return;

	visible[w][h] = true;

	if (!Buildings[w - 1][h]) visibilityDiffusion(w - 1, h);
	if (!Buildings[w + 1][h]) visibilityDiffusion(w + 1, h);
	if (!Buildings[w][h - 1]) visibilityDiffusion(w, h - 1);
	if (!Buildings[w][h + 1]) visibilityDiffusion(w, h + 1);
	if (h % 2 == 1){
		// odd
		if (!Buildings[w + 1][h - 1]) visibilityDiffusion(w + 1, h - 1);
		if (!Buildings[w + 1][h + 1]) visibilityDiffusion(w + 1, h + 1);
	}
	else{
		// even
		if (!Buildings[w - 1][h - 1]) visibilityDiffusion(w - 1, h - 1);
		if (!Buildings[w - 1][h + 1]) visibilityDiffusion(w - 1, h + 1);
	}
}

int main(){
	cin >> W >> H;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			cin >> Buildings[j][i];
		}
	}

	// 建物がない場所のうち、外から見える部分を探索する
	for (int i = 1; i <= W; i++){
		if (!Buildings[i][1]) visibilityDiffusion(i, 1);
		if (!Buildings[i][H]) visibilityDiffusion(i, H);
	}
	for (int i = 1; i <= H; i++){
		if (!Buildings[1][i]) visibilityDiffusion(1, i);
		if (!Buildings[W][i]) visibilityDiffusion(W, i);
	}

	int ans = 0;
	int hole = 0;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			if (Buildings[j][i]){
				ans += 6;
				if (Buildings[j+1][i]) ans -= 2;
				if (Buildings[j][i+1]) ans -= 2;
				if (i % 2 == 1){
					if (Buildings[j+1][i+1]) ans -= 2; // odd
				}
				else{
					if (Buildings[j-1][i+1]) ans -= 2; // even
				}
			}
			else if (!visible[j][i]){
				hole += 6;
				if (!Buildings[j+1][i]) hole -= 2;
				if (!Buildings[j][i+1]) hole -= 2;
				if (i % 2 == 1){
					if (!Buildings[j+1][i+1]) hole -= 2; // odd
				}
				else{
					if (!Buildings[j-1][i+1]) hole -= 2; // even
				}
			}
		}
	}

	cout << ans-hole << endl;
	return 0;
}