$d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
      [ [-1, 0], [0, -1],  [1, 0], [1, 1], [0, 1], [-1, 1]]]
     
def bfs(fld, w, h)
  prt = (h+2).times.map{ [false]*(w+2) }
  arr = []
  arr << [0, 0]
  prt[0][0] = true
  until arr.empty?
    y, x = arr.pop
    $d[y%2].each do |dy, dx|
      u = y + dy; v = x + dx
      next if u < 0 || u > h+1 || v < 0 || v > w+1
      if !fld[u][v] && !prt[u][v]
        prt[u][v] = true
        arr << [u, v]
      end
    end
  end
  (1..h).each do |k|
    (1..w).each do |m|
      fld[k][m] = true unless prt[k][m]
    end
  end
  fld
end

w, h = gets.split.map(&:to_i)
fld = Array.new(h+2)
(1..h).each{ |i| fld[i] = gets.split(" ") }
(1..h).map{ |i| (0...w).map{ |j| fld[i][j] = fld[i][j] == "1" ? true : false } }
fld[1,h].each{ |arr| arr.unshift(false); arr << false }
fld[0] = [false]*(w+2); fld[h+1] = [false]*(w+2)
fld = bfs(fld, w, h)
sum = 0
(1..h).each do |i|
  (1..w).each do |j|
    if fld[i][j]
      $d[i%2].each do |y, x|
        sum += 1 if !fld[i+y][j+x]
      end
    end
  end
end
p sum