#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
using namespace std;
typedef pair<int,int> p;
typedef pair<int,p> P;
typedef pair<p,p> p2;
#define pu push
#define pb push_back
#define mp make_pair
short field[5005][5005]={};
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		field[a][b]=(short)c+1;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			if(field[i][j]>0){
				field[i+1][j]=max((int)field[i+1][j],(int)field[i][j]-1);
				if(j!=n){
					field[i+1][j+1]=max((int)field[i+1][j+1],(int)field[i][j]-1);
				}
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(field[i][j]>0){
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}