#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int w, h;
int field[110][110];
int visit[110][110];
int dx[][6] = {
	{-1, -1, -1, 0, 0, 1},
	{-1, 0, 0, 1, 1, 1},
};
int dy[][6] = {
	{-1, 0, 1, -1, 1, 0},
	{0, -1, 1, -1, 0, 1},
};

int main(){
	cin >> w >> h;
	FOR(i, 1, h+1) FOR(j, 1, w+1) cin >> field[i][j];

	queue<P> q;
	q.push(MP(0, 0));

	int ans = 0;
	while(!q.empty()){
		P p = q.front();
		q.pop();

		if(field[p.Y][p.X]){
			ans++;
			continue;
		}
		if(visit[p.Y][p.X]) continue;
		visit[p.Y][p.X] = 1;

		int k = p.Y&1;
		rep(i, 6){
			int nx = p.X + dx[k][i], ny = p.Y + dy[k][i];
			if(nx < 0 || nx > w+1 || ny < 0 || ny > h+1) continue;
			q.push(MP(nx, ny));
		}
	}

	cout << ans << endl;

    return 0;
}