#include<bits/stdc++.h>
using namespace std;

//#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

int dx[2][6]={{0,1,-1,1,0,1},{-1,0,-1,1,-1,0}};
int dy[6]={-1,-1,0,0,1,1};

int W,H;
int fld[100][100];
bool used[100][100];

void dfs(int y,int x){
    if(fld[y][x]||used[y][x])return;
    used[y][x]=true;
    rep(i,6){
        int ny=y+dy[i],nx=x+dx[y&1][i];
        if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]||used[ny][nx])continue;
        dfs(ny,nx);
    }
}

signed main(){
    cin>>W>>H;
    rep(i,H)rep(j,W)cin>>fld[i][j];

    rep(i,H){
        dfs(i,0);dfs(i,W-1);
    }
    rep(j,W){
        dfs(0,j);dfs(H-1,j);
    }

    int ans=0;
    rep(i,H)rep(j,W)if(fld[i][j])rep(k,6){
        int ny=i+dy[k],nx=j+dx[i&1][k];
        if(ny<0||ny>=H||nx<0||nx>=W||used[ny][nx])ans++;
    }

    cout<<ans<<endl;
    return 0;
}