#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 100

int mo[5] = {0,1,0,-1,0};

int main(){
    int w,h,ans=0,af_f,af_s;
    int mm[110][110]={0};
    bool visited[110][110]={0};
    queue<pair<int,int> > que;
    
    scanf("%d%d",&w,&h);
    
    for(int i=0;i<=w+3;i++){
        visited[0][i] = true;
        visited[h+3][i] = true;
    }
    
    for(int i=0;i<=h+3;i++){
        visited[i][0] = true;
        visited[i][w+3] = true;
    }
    
    
    for(int i=2;i<=h+1;i++){
        for(int j=2;j<=w+1;j++){
            scanf("%d",&mm[i][j]);
        }
    }
    
    /*bfs*/
    que.push(make_pair(1,1));
    
    while(que.size()){
        pair<int,int> p = que.front();
        que.pop();
        
        for(int i=0;i<6;i++){
            
            
            af_f = p.first;
            af_s = p.second;
            
            if(i<4){
                af_f += mo[i];
                af_s += mo[i+1];
            }else{
                if(i==5) af_f-=1;
                else af_f+=1;
                
                if(((int)p.first)%2) af_s-=1;
                else af_s+=1;
            }
            
            if(mm[af_f][af_s]==1){
                ans++;
                
            }else if(visited[af_f][af_s]==false){
                que.push(make_pair(af_f,af_s));
                visited[af_f][af_s]=true;
            }
        }
        
    }
    
    printf("%d\n",ans);
    
    return 0;
}