#include <bits/stdc++.h>
using namespace std;
#define rrep(i,n) for(int i = 1;i <= n;i++)

int dy[6] = {0, -1, -1, 0, 1, 1};
int dx[2][6] = {{-1,-1,0,1,0,-1},{-1,0,1,1,1,0}};
int a[110][110], f[110][110], w, h;

bool check(int y, int x){
	if(y < 0 || h+1 < y)return 1;
	if(x < 0 || w+1 < x)return 1;
	return 0;
}

int solve(int y, int x){
	if(check(y, x))return 0;
	if(a[y][x])return 1;
	if(f[y][x])return 0;
	f[y][x] = 1;
	
	int ans = 0;
	for(int i = 0;i < 6;i++){
		ans += solve(y+dy[i], x+dx[y%2][i]);
	}
	return ans;
}
int main(){
	scanf("%d%d", &w, &h);
	rrep(i,h)rrep(j,w)scanf("%d", &a[i][j]);
	
	int ans = solve(0, 0);
	/*for(int i = 0;i <= h+1;i++){
		for(int j = 0;j <= w+1;j++)printf("%d ", f[i][j]);
		printf("\n");
	}*/
	printf("%d\n", ans);
	return 0;
}
/*
8 4
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 0
1 0 1 0 1 1 1 1
0 1 1 0 1 0 1 0

8 5
0 1 1 1 0 1 1 1
0 1 0 0 1 1 0 0
1 0 0 1 1 1 1 1
0 1 0 1 1 0 1 0
0 1 1 0 1 1 0 0
*/
