#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int odd_mx[]  = { 1, 1, 1,  0, -1,  0};
int even_mx[] = { 0, 1, 0, -1, -1, -1};
int my[]	  = {-1, 0, 1,  1,  0, -1};


int main()
{

	int H, W, cnt = 0;
	int MAP[102][102];
	bool visited[102][102];
	queue< pair<int, int> > search_info;

	memset(MAP, 0, sizeof(MAP));
	memset(visited, false, sizeof(visited));

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

	search_info.push(make_pair(0, 0));
	visited[0][0] = true;

	while(!search_info.empty()) {
		pair<int, int> now = search_info.front();
		search_info.pop();

		for(int i = 0; i < 6; i++) {
			int nx = now.first  + (now.second % 2 ? odd_mx[i] : even_mx[i]);
			int ny = now.second + my[i];

			if(nx >= 0 && nx <= W + 1 && ny >= 0 && ny <= H + 1) {
				if(MAP[ny][nx]) {
					cnt++;
				}
			}
			if(nx >= 0 && nx <= W + 1 && ny >= 0 && ny <= H + 1 && !MAP[ny][nx] && !visited[ny][nx]) {
				visited[ny][nx] = true;
				search_info.push(make_pair(nx, ny));
			}
		}
	}

	cout << cnt << endl;

	return 0;

}