$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)
 
  fld
end

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, idx| fld[i][idx+1] = true if e == "1" }
end

#bfs
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

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