#include<cstdio>
#include<algorithm>
using namespace std;

int n,m;
int a,b,x;
short dp[5000][5000];

int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++)
    for(int j=0;j<=i;j++)dp[i][j] = -1;

  for(int i=0;i<m;i++){
    scanf("%d%d%d",&a,&b,&x);
    a--; b--;
    dp[a][b] = max(dp[a][b],(short)x);
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      if(i){
	dp[i][j] = max(dp[i][j],(short)(dp[i-1][j]-1));
	if(j)dp[i][j] = max(dp[i][j],(short)(dp[i-1][j-1]-1));
      }
    }
  }

  int ans = 0;
  for(int i=0;i<n;i++)
    for(int j=0;j<=i;j++)
      if(0<=dp[i][j])ans++;
  printf("%d\n",ans);
}