#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int num = 0;

int w, h;
bool arr[100][100] = {};
bool arr_gp[100][100] = {};


bool ar_arr[102][102] = {};


struct P { int x, y; };

struct YLess
{
    bool operator()( P const& l, P const& r ) const
    {
        return l.y < r.y;
    }
};

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

void count( int const x, int const y )
{
    for( int i=0; i<6; ++i ) {
        int const nx = x + dir[y%2][i][0], ny = y + dir[y%2][i][1];
        cout << nx << " : " << ny << endl;
        if ( nx < 0 || ny < 0 || nx >= w || ny >= h ) {
        }

        // if ( arr[nx][ny] )

    }
}


void count_s( int const x, int const y )
{
    if ( !arr[x][y] )
        return;

    count( x, y );
}





void groupe( vector<P>* const p, int const x, int const y )
{
    P pt = { x, y };
    p->push_back( pt );
    arr_gp[x][y] = false;

    for( int i=0; i<6; ++i ) {
        int const nx = x + dir[y%2][i][0], ny = y + dir[y%2][i][1];
        cout << nx << " : " << ny << endl;
        if ( nx < 0 || ny < 0 || nx >= w || ny >= h )
            continue;

        if ( arr_gp[nx][ny] )
            groupe( p, nx, ny );

    }
}

vector<P>* group_s( int const x, int const y )
{
    if ( !arr_gp[x][y] )
        return 0;

    vector<P>* p = new vector<P>();
    groupe( p, x, y );
    return p;
}



void outer_group( vector<P>& v, int const x, int const y )
{
    ar_arr[x][y] = true;

    if ( x >= 1 && y >= 1 && x <= w && y <= h ) {
        P pt = { x-1, y-1 };
        v.push_back( pt );
    }

    for( int i=0; i<6; ++i ) {
        int const nx = x + dir[y%2][i][0], ny = y + dir[y%2][i][1];
        if ( nx < 0 || ny < 0 || nx > w+1 || ny > h+1 )
            continue;

        // cout << nx << ", " << ny << " == " << ar_arr[nx][ny] << endl;
        if ( ar_arr[nx][ny] == false )
            outer_group( v, nx, ny );

    }
}




int main()
{
    
    cin >> w >> h;

    vector<P> sp;
    for( int y=0; y<h; ++y ) {
        for( int x=0; x<w; ++x ) {
            int is;
            cin >> is;
            if ( is == 1 ) {
                arr[x][y] = true;
                arr_gp[x][y] = true;
                
                ar_arr[x+1][y+1] = true;

                P p = { x, y };
                sp.push_back( p );
            }
        }
    }



    vector<P> outer;
    outer_group( outer, 0, 0 );
    bool bbb[100][100] = {};

    for( size_t j=0; j<outer.size(); ++j ) {
        bbb[outer[j].x][outer[j].y] = true;
        //cout << outer[j].x+1 << "/" << outer[j].y+1 << endl;
    }
    //cout << "-----" << endl;


    for( int y=0; y<h; ++y ) {
        for( int x=0; x<w; ++x ) {
            if ( !arr_gp[x][y] )
                continue;

            //cout << x+1 << " / " << y+1 << endl;
            int ln = 0;

            for( int i=0; i<6; ++i ) {
                int const nx = x + dir[(y+1)%2][i][0], ny = y + dir[(y+1)%2][i][1];
                //cout << nx+1 << " : " << ny+1 << "  =  ";
                if ( nx < 0 || ny < 0 || nx >= w || ny >= h ) {
                    ++ln;
                    //cout << "!";
                    continue;
                }

                if ( !arr_gp[nx][ny] && bbb[nx][ny] ) {
                    ++ln;
                    //cout << "!";
                }
            }
            //cout << ln << endl;
            num += ln;
        }
    }



#if 0
    
    vector<vector<P>*> group;
    for( size_t iii=0; iii<sp.size(); ++iii ) {
        vector<P>* pt = group_s( sp[iii].x, sp[iii].y );
        if ( pt ) {
            sort( pt->begin(), pt->end(), YLess() );
            group.push_back( pt );
        }
    }


    for( size_t iii=0; iii<group.size(); ++iii ) {
        for( size_t j=0; j<group[iii]->size(); ++j ) {
            cout << group[iii]->at(j).x+1 << " " << group[iii]->at(j).y+1 << endl;
        }
        cout << "-----" << endl;
    }


    //for( size_t iii=0; iii<sp.size(); ++iii ) {
    //    count_s( sp[iii].x, sp[iii].y );
    //}
#endif
    cout << num << endl;
}

Measured memory_bytes: 1808