#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

short dp[5002][5002];
void dfs(int x,int y,int depth){
    if(dp[y][x]>=depth)return;
    dp[y][x]=depth;
    if(depth==0)return;
    int ny=y+1;
    int nx=x+1;
    dfs(nx,ny,depth-1);
    ny=y;
    dfs(nx,ny,depth-1);
}

void solve(){
    memset(dp,-1,sizeof(dp));
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y,a;
        cin>>x>>y>>a;
        dp[x][y]=a;
        //dfs(x,y,a);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            dp[i+1][j+1]=max(dp[i+1][j+1],(short)(dp[i][j]-1));
            dp[i+1][j]=max(dp[i+1][j],(short)(dp[i][j]-1));
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            if(dp[i][j]>=0)cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main(){

    solve();

    return 0;
}