object Main {
  def main(args: Array[String]): Unit = {
    val firstLine = scala.io.StdIn.readLine().split(" ");
    val n = firstLine(0).toInt
    val m = firstLine(1).toInt

    val checked = new Array[Byte](n * (n + 1) / 2)
    val one = 1.byteValue()

    System.gc();
    var a = 0;
    var b = 0;
    var x = 0;

    var count = 0
    for (mcount <- 1 to m) {
      val line = scala.io.StdIn.readLine
      val lineArray = line.split(" ");
      a = lineArray(0).toInt
      b = lineArray(1).toInt
      x = lineArray(2).toInt

      var i = a * (a - 1) / 2 + b - 1
      for (p <- a to a + x) {
        for (q <- b to b + p - a) {
          if (checked(i) != one) {
            checked(i) = one
            count += 1;
          }

          i += 1
        }
        i += a - 1
      }
      System.gc();
    }

    println(count)
  }
}