#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
short flag[5005][5005];
int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  for(int i = 0; i < M; i++){
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    flag[A][B] = max< short >( flag[A][B], C + 1);
  }
  int ret = 0;
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= i; j++){
      flag[i][j] = max< short >( flag[i][j], max( flag[i - 1][j - 1], flag[i - 1][j]) - 1);
      if(flag[i][j] > 0) ret++;
    }
  }
  cout << ret << endl;
}