#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  vector<vector<int> > masu(5005);
  for (int i = 0; i < masu.size(); i++) {
    for (int j = 0; j < i+5; j++) {
      masu[i].push_back(0);
    }
  }


  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b, x;
    cin >> a >> b >> x;
    masu[a][b]++;
    masu[a][b+1]--;
    masu[a+x+1][b]--;
    masu[a+x+1][b+x+2]++;
    masu[a+x+2][b+1]++;
    masu[a+x+2][b+x+2]--;
  }

  // 左から右
  for (int i = 1; i <= n; i++) {
    for (int j = 2; j <= i; j++) {
      masu[i][j] += masu[i][j-1];
    }
  }

  // 上から下
  for (int j = 1; j <= n; j++) {
    for (int i = j+1; i <= n; i++) {
      masu[i][j] += masu[i-1][j];
    }
  }

  // 左上から右下
  for (int i = 1; i <= n; i++) {
    for (int j = i+1; j <= n; j++) {
      masu[j][j-i+1] += masu[j-1][j-i];
    }
  }

  int num = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (masu[i][j] >= 1) {
        num++;
      }
    }
  }

  cout << num << endl;
  return 0;
}