#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int dx[]={0,1,-1,1,0,1};
int dy[]={-1,-1,0,0,1,1};
int dx2[]={-1,0,-1,1,-1,0};
int dy2[]={-1,-1,0,0,1,1};
int a[200][200],ans,h,w;
void dfs(int x,int y){
  a[y][x]=2;
  if(y%2==0)r(i,6){
    int yy=y+dy[i];
    int xx=x+dx[i];
    if(yy<0||xx<0||yy>190||xx>190)continue;
    if(a[yy][xx]==0) dfs(xx,yy);
  }
  else r(i,6){
    int yy=y+dy2[i];
    int xx=x+dx2[i];
    if(yy<0||xx<0||yy>190||xx>190)continue;
    if(a[yy][xx]==0) dfs(xx,yy);
  }
}
int main(){
  cin>>w>>h;
  r(i,h)r(j,w)cin>>a[i+50][j+50];
  dfs(0,0);
  r(i,200)r(j,200)if(a[i][j]==1){
    if(i%2==0)r(k,6){
      int y=i+dy[k];
      int x=j+dx[k];
      if(a[y][x]==2)ans++;
    }
    else r(k,6){
      int y=i+dy2[k];
      int x=j+dx2[k];
      if(a[y][x]==2)ans++;
    }
  }
  cout<<ans<<endl;
}