#include <iostream>
#include <utility> // pair
#include <queue>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

typedef pair<int,int> P;

#define mp make_pair
#define ft first
#define sd second

int w, h;
int d[100][100];

P sp[6];
int t;

void set_d(int i, int j) {
	queue<P> q;
	q.push(mp(i, j));
	P p;
	while(!q.empty()) {
		p = q.front();
		q.pop();
		if(p.ft<0 || p.ft>=w)continue;
		if(p.sd<0 || p.sd>=h)continue;
		if(d[p.ft][p.sd])continue;
		d[p.ft][p.sd] = 2;
		P sp[6];
		rep(i, 6) {
			sp[i] = mp( p.ft+(i%2)-(p.sd&1), p.sd-1+(i/2) );
		}
		if(p.sd&1) sp[3].ft += 1;
		else sp[2].ft -= 1;
		rep(i, 6) q.push(sp[i]);
	}
}

int main() {
	cin >> w >> h;
	
	rep(i, h) {
		rep(j, w) cin >> d[j][i];
	}
	
	rep(i, h) set_d(0, i);
	rep(i, h) set_d(w-1, i);
	rep(i, w) set_d(i, 0);
	rep(i, w) set_d(i, h-1);
	
	int s = 0;
	rep(i, w) {
		rep(j, h) {
			if(d[i][j]!=1) continue;
			P p[6];
			rep(k, 6) {
				p[k] = mp( i+(k%2)-(j&1), j-1+(k/2) );
			}
			if(j&1) p[3].ft += 1;
			else p[2].ft -= 1;
			rep(k, 6) {
				if( (p[k].ft<0 || p[k].ft>=w) || (p[k].sd<0 || p[k].sd>=h) ) {
					s++;
				}else if(d[p[k].ft][p[k].sd]==2) {
					s++;
				}
			}
		}
	}
	
	cout << s << endl;
	
	return 0;
}