#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int n,m;
vvi in;
int dx[6]={-1,-1,0,0,1,1};
int dy[2][6]={
	{-1,0,-1,1,-1,0},
	{0,1,-1,1,0,1}
};
void f(int x,int y){
	in[x][y]=2;
	rep(i,6){
		int nx=x+dx[i];
		int ny=y+dy[x%2][i];
		if(nx<0||ny<0||nx>=n+2||ny>=m+2)continue;
		if(in[nx][ny]==0)f(nx,ny);
	}
}
int main(){
	cin>>m>>n;
	in=vvi(n+2,vi(m+2));
	rep(i,n)rep(j,m)cin>>in[i+1][j+1];
	f(0,0);
	int co=0;
	rep(i,n+2)rep(j,m+2)if(in[i][j]==1){
		rep(k,6)if(in[i+dx[k]][j+dy[i%2][k]]==2)co++;
	}
//	rep(i,n+2){rep(j,m+2)cout<<" "<<in[i][j];cout<<endl;}
	cout<<co<<endl;
}