### subroutines

def xy2id(ai, bi)
  (ai * (ai + 1) / 2) + bi
end

def print_pl(n, pl)
  for ai in (0...n)
    id0 = xy2id(ai, 0)
    id1 = id0 + ai
    p pl[id0..id1]
  end
end

### main

n, m = gets.strip.split(' ').map{|s| s.to_i}

nn = n * (n + 1) / 2
pl = nn.times.map{0}

m.times do
  ai, bi, xi = gets.strip.split(' ').map{|s| s.to_i}
  pl[xy2id(ai - 1, bi - 1)] = xi + 1
  #p [ai, bi, xi]
end
#print_pl(n, pl)

count = 0

for ai in (0...n)
  nxta = (ai < (n - 1))
  for bi in (0..ai)
    id  = xy2id(ai, bi)
    plid = pl[id]
    if plid > 0
      count += 1
      if plid > 1 && nxta
        plid -= 1
        id0 = xy2id(ai + 1, bi)
        pl[id0] = plid if pl[id0] < plid
        id1 = id0 + 1
        pl[id1] = plid if pl[id1] < plid
      end
    end
  end
end
#print_pl(n, pl)

puts count