#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int w,h;
int d[200][200];
int dy[]={-1,-1,1,0,1,0},dx[]={-1,0,-1,1,0,-1};
int xx[]={0,1,1,1,0,-1};
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w,h;cin >> w >> h;
    int ans=0;
    rep(i,0,105){
        rep(j,0,105){
            d[i][j]=0;
        }
    }
    rep(i,1,h+1){
        rep(j,1,w+1){
            cin >> d[i][j];
        }
    }
    bool used[105][105];
    rep(i,0,105)rep(j,0,105)used[i][j]=false;
    queue<pii> que;
    que.push(mp(0,0));
    while(!que.empty()){
        pii q=que.front();que.pop();
        int y=q.first;
        int x=q.second;
        if(!used[y][x]){
        used[y][x]=true;
        rep(i,0,6){
            int ddx,ddy;
            if(!(y&1)){
                ddx=x+dx[i];
            }else{
                ddx=x+xx[i];
            }
            ddy=y+dy[i];
            if(ddx>=0&&ddy>=0&&ddx<=(w+2)&&ddy<=(h+2)){
                if(d[ddy][ddx]){
                    //cout << ddy << " " << ddx << endl;
                    ans++;
                }else{
                    que.push(mp(ddy,ddx));
                }
            }
        }
        //cout << x << " " << y << " " << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}