#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int field[128][128];
int dx[2][6]={{-1,0,1,0,-1,-1},
	      {0,1,1,1,0,-1}};
int dy[2][6]={{-1,-1,0,1,1,0},
	      {-1,-1,0,1,1,0}};
int H, W;

void dfs(int y, int x){
  if(field[y][x]==1||field[y][x]==2) return;
  //  cout << y << " " << x << endl;
  field[y][x] = 2;
  for(int d = 0; d < 6; d++){
    int ny=y+dy[(y%2)][d], nx=x+dx[(y%2)][d];
    if(ny<0||ny>H+1||nx<0||nx>W+1) continue;
    dfs(ny, nx);
  }
  return;
}

int main(){
  cin >> W >> H;
  memset(field, -1, sizeof(field));
  rep(i, H) rep(j, W) cin >> field[i+1][j+1];
  for(int i = 0; i < H; i++){dfs(i, 0);dfs(i, W+1);}
  for(int i = 0; i < W; i++){dfs(0, i);dfs(H+1, i);}
  int res = 0;
  /*  for(int i = 0; i <= H+1; i++){
    for(int j = 0; j <= W+1; j++) cout << field[i][j] << " ";
    cout << endl;
    }*/
  for(int i = 0; i <= H+1; i++){
    for(int j = 0; j <= W+1; j++){
      if(field[i][j]!=2) continue;
      for(int d = 0; d < 6; d++){
	int ny=i+dy[(i%2)][d], nx=j+dx[(i%2)][d];
	if(ny<0||ny>H+1||nx<0||nx>W+1) continue;
	if(field[ny][nx]==1) res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}