#include<stdio.h>
int tate,yoko;
int dx[2][6] = {{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}};
int dy[6] = {1,1,0,-1,-1,0,};
int field[110][110] = {0};
int drow(int x,int y)
{
    int sum = 0;
    field[x][y] = 2;
    for(int i = 0; i < 6; i++)
    {
        if(0 > x + dx[y % 2][i] || x + dx[y % 2][i] > yoko + 1 || 0 > y + dy[i] || y + dy[i] > tate + 1);
        else if(field[x + dx[y % 2][i]][y + dy[i]] == 1)sum++;
        else if(field[x + dx[y % 2][i]][y + dy[i]] == 0)
            sum = sum + drow(x + dx[y % 2][i],y + dy[i]);
    }
    return sum;
}
int main()
{
    scanf("%d%d",&yoko,&tate);
    for(int i = 1; i <= tate; i++)
        for(int j = 1; j <= yoko; j++)
            scanf("%d",&field[j][i]);
    printf("%d\n",drow(0,0));
    return 0;
}