#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
using namespace std;

int a[5001][5001], b[5001][5001];
int c[5001][5001];
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y, z; cin >> x >> y >> z; x--; y--;
		a[x][y]++;
		a[x+z+1][y]--;
		b[x][y + 1]--;
		b[x+z+1][y + z + 2]++;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			a[i][j] += a[i - 1][j];
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= i; j++) {
			b[i][j] += b[i - 1][j - 1];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			if(j)c[i][j] = c[i][j-1] + a[i][j] + b[i][j];
			else c[i][j] = a[i][j] + b[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			if (c[i][j]) { ans++;  }
		}
	}
	cout << ans << endl;
}