#include <bits/stdc++.h>
using namespace std;
pair<int, int> adjacent_xy(int x, int y, int i) // i は隣接する正六角形の番号
{
int dy[] = {0, -1, -1, 0, 1, 1};
int dx1[] = {1, 1, 0, -1, 0, 1};
int dx2[] = {1, 0, -1, -1, -1, 0};
if (y % 2 == 1)
return {x + dx1[i], y + dy[i]};
return {x + dx2[i], y + dy[i]};
}
int main()
{
int grid[102][102] = {};
bool seen[102][102] = {};
int W, H;
cin >> W >> H;
W += 2;
H += 2;
for (int i = 1; i < H - 1; ++i) {
for (int j = 1; j < W - 1; ++j)
cin >> grid[i][j];
}
queue<pair<int, int>> que;
que.push({0, 0});
seen[0][0] = true;
int cnt = 0;
while (!que.empty()) {
auto pr = que.front();
que.pop();
int x = pr.first;
int y = pr.second;
for (int i = 0; i < 6; ++i) {
auto next = adjacent_xy(x, y, i);
int x2 = next.first;
int y2 = next.second;
if (y2 < 0 || H <= y2 || x2 < 0 || W <= x2)
continue;
if (grid[y2][x2] == 1) {
++cnt;
continue;
}
if (seen[y2][x2])
continue;
que.push({x2, y2});
seen[y2][x2] = true;
}
}
cout << cnt << endl;
}