#include <cstdio>

int zari(int i,int j){
  return (i*(i+1)/2+j);
}
int n,m;
int maps[5000*2505]={0};
int main(void){

  //釘(i,j)をmaps[i*(i+1)/2+j]とする。
  scanf("%d%d",&n,&m);
  int i,j;
  int a,b,c;
  for(i=0;i<m;i++){
    scanf("%d%d%d",&a,&b,&c);
    a+=1;//b--;
    maps[zari(a,b)]+=1;
    maps[zari(a,b+1)]+=-1;
    maps[zari(a+c+1,b)]+=-1;
    maps[zari(a+c+2,b+1)]+=1;
    maps[zari(a+c+1,b+c+2)]+=1;
    maps[zari(a+c+2,b+c+2)]+=-1;
    }
 


  for(i=1;i<=n+3;i++){
    for(j=1;j<=i;j++){
      maps[zari(i,j)]+=maps[zari(i,j-1)];
    }
  }


  for(j=0;j<=n+3;j++){

    for(i=j;i<=n+3;i++){
       maps[zari(i,j)]+=maps[zari(i-1,j)];
    }

 
  }

  int ans=0;
  for(i=1;i<=n+3;i++){
    //for(j=0;j<i*2;i++)printf("\x0020");
    for(j=1;j<=i;j++){
       maps[zari(i,j)]+=maps[zari(i-1,j-1)];
      if(maps[zari(i,j)]!=0)ans++;
      //printf("%d\x0020",maps[zari(i,j)]);
    }
    //printf("\n");
  }
  printf("%d\n",ans);
  return 0;
}