//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
short dp[5005][5005]={};
int main()
{
	srand((unsigned int)time(NULL));
	int n,q; scanf("%d %d",&n,&q);
	for(int i=0;i<q;i++)
	{
		int x,y,v; scanf("%d%d%d",&x,&y,&v);
		dp[x][y]=max(dp[x][y],(short)++v);
	}
	int ret=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(!dp[i][j]) continue;
			ret++;
			dp[i+1][j]=max(dp[i+1][j],--dp[i][j]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]);
		}
	}
	printf("%d\n",ret);
}