#include <iostream>
#include <algorithm>
using namespace std;

int il[105][105] = { 0 };
int w, h;
int dx[2][6] = { {0,1,1,1,0,-1} ,{ -1,0,1,0,-1,-1 } }, dy[] = { -1,-1,0,1,1,0 };
int res = 0;

void dfs(int nowy, int nowx) {
	il[nowy][nowx] = -1;
	for (int i = 0; i < 6; i++) {
		int ny = nowy + dy[i];
		int nx = 0;
		if (nowy % 2) nx = nowx + dx[0][i];
		else nx = nowx + dx[1][i];
		if (0 <= ny&&ny <= h+1 && 0 <= nx&&nx <= w+1) {
			if (il[ny][nx] == 1) res++;
			if (il[ny][nx] == 0) dfs(ny, nx);
		}
	}
	return;
}

int main() {
	cin >> w >> h;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> il[i][j];
		}
	}
	dfs(0, 0);
	cout << res << endl;
	return 0;
}
