#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef long long ll;
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"         here"<<en
#define out(value) cout<<value<<en

int building[105][105];
int ranking[105][105];
bool done[105][105];

int zero_ilumi_x[6]={1,0,-1,-1,-1,0};
int zero_ilumi_y[6]={0,1,1,0,-1,-1};
int one_ilumi_x[6]={1,0,-1,0,1,1};
int one_ilumi_y[6]={0,1,0,-1,1,-1};


int main(){
  int w,h;
  cin>>w>>h;
  
  for(int i=1; i<=h; i++) for(int j=1; j<=w; j++){
    cin>>building[i][j];
    done[i][j]=false;
    if(building[i][j]) continue;
    if(i==1||j==1||i==h||j==w) ranking[i][j]=1;
  }
  
//  cout<<endl<<en
//  for(int i=1; i<=h; i++){
//    for(int j=1; j<=w; j++){
//      if(i%2==0) cout<<building[i][j]<<" ";
//      else cout<<" "<<building[i][j];
//    }
//    cout<<en
//  }
//  cout<<en
  
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(done[i][j]) continue;
      if(building[i][j]) continue;
      if(i==1||i==h||j==1||j==w){
        ranking[i][j]=1;
        done[i][j]=1;
        stack<P> que;
        que.push(mk(i,j));
        while(!que.empty()){
          P p=que.top(); que.pop();
          int yy=p.first,xx=p.second;
//          cout<<"               yy: "<<yy<<"   xx: "<<xx<<en
          if(yy%2==0){
            for(int k=0; k<6; k++){
              int x=xx+zero_ilumi_x[k];
              int y=yy+zero_ilumi_y[k];
              if(x<1||x>w||y<1||y>h) continue;
              if(done[y][x]==1) continue;
              if(building[y][x]==1) continue;
              
              done[y][x]=1;
              ranking[y][x]=1;
              que.push(mk(y,x));
            }
          }else{
            for(int k=0; k<6; k++){
              int x=xx+one_ilumi_x[k];
              int y=yy+one_ilumi_y[k];
              if(x<1||x>w||y<1||y>h) continue;
              if(done[y][x]==1) continue;
              if(building[y][x]==1) continue;
              
              done[y][x]=1;
              ranking[y][x]=1;
              que.push(mk(y,x));
            }
          }
        }
      }
    }
  }
  
  
  
//  cout<<endl<<en
//  for(int i=1; i<=h; i++){
//    for(int j=1; j<=w; j++){
//      if(i%2==0) cout<<ranking[i][j]<<" ";
//      else cout<<" "<<ranking[i][j];
//    }
//    cout<<en
//  }
//  cout<<en
  
  int ans=0;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      int a=ans;
      if(building[i][j]==0) continue;
      if(i%2==0){
        for(int k=0; k<6; k++){
          int x=j+zero_ilumi_x[k];
          int y=i+zero_ilumi_y[k];
          
          if(y<1||y>h||x<1||x>w) {
            ans++;
            continue;
          }
          if(ranking[y][x]==1) ans++;
          
        }
      }else{
        for(int k=0; k<6; k++){
          int x=j+one_ilumi_x[k];
          int y=i+one_ilumi_y[k];
          
          if(y<1||y>h||x<1||x>w){
            ans++;
            continue;
          }
          if(ranking[y][x]==1) ans++;
        }
      }
      
//      cout<<"   ans+= "<<ans-a<<"  (i : "<<i<<"  j: "<<j<<en
    }
//    cout<<en
  }
  
  cout<<ans<<en
}



Measured memory_bytes: 3264