#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;

int w, h;
int a[102][102];
int odx[6] = {1, 1, 1, 0, -1, 0};
int edx[6] = {0, 1, 0, -1, -1, -1};
int dy[6] = {-1, 0, 1, 1, 0, -1};
int ans;
typedef pair<int, int> P;
queue<P> q;

void bfs(){
	q.push(P(0, 0));
	a[0][0] = -1;
	while(q.size()){
		P p = q.front();
		q.pop();
		for(int i=0; i<6; i++){
			int nx, ny;
			ny = p.second + dy[i];
			if(p.second % 2 == 1){
				nx = p.first + odx[i];
			}else{
				nx = p.first + edx[i];
			}
			if(0 <= nx && nx < w+2 && 0 <= ny && ny < h+2 && a[nx][ny] != -1){
				if(a[nx][ny] == 0){
					q.push(P(nx, ny));
					a[nx][ny] = -1;
				}else{
					ans++;
				}
			}
		}
	}
}

int main(){
	scanf("%d %d", &w, &h);
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			scanf("%d", &a[j+1][i+1]);
		}
	}
	bfs();
	printf("%d\n", ans);
	return 0;
}