#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int a[110][110], b[110][110];

void dfs(int y, int x) {
  if (b[y][x] == 1) return;
  if (a[y][x] == 1) return;
  b[y][x] = 1;
  if (y % 2 == 0) {
    dfs(y - 1, x);
    dfs(y - 1, x + 1);
    dfs(y, x - 1);
    dfs(y, x + 1);
    dfs(y + 1, x);
    dfs(y + 1, x + 1);
  } else {
    dfs(y - 1, x - 1);
    dfs(y - 1, x);
    dfs(y, x - 1);
    dfs(y, x + 1);
    dfs(y + 1, x - 1);
    dfs(y + 1, x);
  }
}

int main() {
  int w, h;
  cin >> w >> h;
  rep (i, h + 4) a[i][0] = 1;
  rep (i, h + 4) a[i][w + 3] = 1;
  rep (i, w + 4) a[0][i] = 1;
  rep (i, w + 4) a[h + 3][i] = 1;
  rep (i, h) rep (j, w) cin >> a[i + 2][j + 2];
  dfs(1, 1);
  rep (i, h + 4) a[i][0] = 0;
  rep (i, h + 4) a[i][w + 3] = 0;
  rep (i, w + 4) a[0][i] = 0;
  rep (i, w + 4) a[h + 3][i] = 0;
  int res = 0;
  rep (i, h + 4) rep (j, w + 4) if (b[i][j] == 1) {
    if (i % 2 == 0) {
      if (a[i - 1][j] == 1) ++res;
      if (a[i - 1][j + 1] == 1) ++res;
      if (a[i][j - 1] == 1) ++res;
      if (a[i][j + 1] == 1) ++res;
      if (a[i + 1][j] == 1) ++res;
      if (a[i + 1][j + 1] == 1) ++res;
    } else {
      if (a[i - 1][j - 1] == 1) ++res;
      if (a[i - 1][j] == 1) ++res;
      if (a[i][j - 1] == 1) ++res;
      if (a[i][j + 1] == 1) ++res;
      if (a[i + 1][j - 1] == 1) ++res;
      if (a[i + 1][j] == 1) ++res;
    }
  }
  cout << res << endl;
  return 0;
}