#include<bits/stdc++.h>
using namespace std;

void solve();

int N,M;
int ans = 0;
int fid[5010][5010] = {0};

int main()
{
    scanf("%d%d",&N,&M);
    solve();
}

void solve()
{
    int a,b,x;
    for(int i = 0; i < M; i++)
    {
        scanf("%d%d%d",&a,&b,&x);
        fid[a - 1][b- 1] = x + 1;
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            int mem = fid[i][j];
            if(i == 0);
            else if(j == 0)
            {
                fid[i][j] = max(fid[i - 1][j] - 1,mem);
            }
            else if(i == j)
            {
                fid[i][j] = max(fid[i - 1][j - 1] - 1,mem);
            }
            else
            {
                fid[i][j] = max
                           (max(
                            fid[i - 1][j] - 1,fid[i - 1][j - 1] - 1),mem);
            }
            if(fid[i][j])ans++;
        }
    }
    printf("%d\n",ans);
}