import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    const M = 102;
    int F[M][M];
    int W, H; scanf("%d %d\n", &W, &H);
    foreach (i; 1 .. H + 1) {
        foreach (j; 1 .. W + 1) {
            int d; scanf("%d", &d);
            F[i][j] = d;
        }
    }

    bool used[M][M];
    static const 
        dy = [
            [-1, -1, 0, 0, 1, 1,], 
            [-1, -1, 0, 0, 1, 1,], 
        ],
        dx = [
            [-1, 0, -1, 1, -1, 0], // y is even
            [0, 1, -1, 1, 0, 1], // y is odd
        ];
    void dfs(int y, int x) {
        foreach (i; 0 .. 6) {
            int ny = y + dy[y % 2][i],
                nx = x + dx[y % 2][i];
            if (ny < 0 || ny >= M) continue;
            if (nx < 0 || nx >= M) continue;
            if (used[ny][nx]) continue;
            used[ny][nx] = true;
            if (F[ny][nx]) continue;
            dfs(ny, nx);
        }
    }
    dfs(0, 0);
    int ans = 0;
    foreach (i; 0 .. M) {
        foreach (j; 0 .. M) {
            if (F[i][j] && used[i][j]) {
                foreach (k; 0 .. 6) {
                    int ny = i + dy[i % 2][k],
                        nx = j + dx[i % 2][k];
                    if (ny < 0 || ny >= M) continue;
                    if (nx < 0 || nx >= M) continue;
                    if (!F[ny][nx] && used[ny][nx]) ans++;
                }
            }
        }
    }
    ans.writeln;
}