#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXIST2(s,e) (find(ALL(s),(e))!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dx[2][6]={{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}},dy[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};

	int w,h;

int dfs(vvi &m,int y,int x,vvi &used){
	used[y][x]=1;
	int ret=0;
	REP(i,6){
		int yy=y+dy[y%2][i];
		int xx=x+dx[y%2][i];
		if(yy>=0&&xx>=0&&yy<h+6&&xx<w+6){
			if(m[yy][xx]){
				ret++;
			}else if(!used[yy][xx]){
				ret+=dfs(m,yy,xx,used);
			}
		}
	}
	return ret;
}

int main(){
	cin>>w>>h;
	vvi m(h+6,vi(w+6));
	REP(i,h){
		REP(j,w){
			cin>>m[i+3][j+3];
		}
	}
	int ans=0;
	vvi used(h+6,vi(w+6));

	ans+=dfs(m,0,0,used);
	cout<<ans<<endl;
}