#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 5010

int main(){
    vector<int > nails[SIZE+3];
    int n,m,a,b,x,ans=0;
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<=n+2;i++){
        nails[i].resize(i+5,0);
    }
    
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&a,&b,&x);
        
        nails[a][b]++;
        nails[a][b+1]--;
        nails[a+x+1][b]--;
        nails[a+x+2][b+1]++;
        nails[a+x+1][b+x+2]++;
        nails[a+x+2][b+x+2]--;
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            nails[i][j+1]+=nails[i][j];
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            nails[i+1][j]+=nails[i][j];
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            nails[i+1][j+1]+=nails[i][j];
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            if(nails[i][j]>0)
                ans++;
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}