#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int sum[5005][5005];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int a, b, x; scanf("%d%d%d", &a, &b, &x);
		sum[a][b]++; sum[a][b + 1]--;
		sum[a + x + 1][b]--; sum[a + x + 2][b + 1]++;
		sum[a + x + 1][b + x + 2]++; sum[a + x + 2][b + x + 2]--;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i + 1; j++)sum[i][j] += sum[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i + 1; j++)sum[i][j] += sum[i - 1][j];
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i + 1; j++) {
			sum[i][j] += sum[i - 1][j - 1]; cnt += (sum[i][j] > 0);
		}
	printf("%d\n", cnt);
}