#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
	vector<pair<int,int> >a[5000];
	int b[5010];
	int d[5010];
	for (int i = 0; i < 5010; i++){
		b[i] = 0;
		d[i] = 0;
	}
	int c;
	int n, m;
	int x, y, z;
	c = 0;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		scanf("%d %d %d", &x, &y, &z);
		a[x-1].push_back(make_pair(y-1, z+1));
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < i+1; j++){
			if (b[j] > 0){
				if (d[j] < b[j] - 1)d[j] = b[j] - 1;
				d[j + 1] = b[j] - 1;
			}
		}
		for (int j = 0; j < a[i].size(); j++){	
			if (d[a[i][j].first] < a[i][j].second){
				d[a[i][j].first] = a[i][j].second;

			}
		}
		for (int j = 0; j < i+1; j++){
			b[j] = d[j];
			if (b[j] > 0){
				c++;
			}
			d[j] = 0;
		}
	}
	printf("%d\n", c);

	return 0;
}