#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

short board[5001][5001];
int main() {
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++){
		int a,b,x;
		scanf("%d%d%d",&a,&b,&x);
		board[a][b]=max(board[a][b],(short)(x+1));
	}
	int ret=0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=i;j++){
			board[i][j]=max((int)board[i][j],board[i-1][j]-1);
			board[i][j]=max((int)board[i][j],board[i-1][j-1]-1);
			if(board[i][j]){
				ret++;
			}
			//cout << i << ", " << j << ": " << board[i][j] << endl;
		}
	}
	printf("%d\n",ret);
}