#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 5000
int g[N+1][N+1];
void add(int n, int i, int j, int v) {
    if(1 <= i and i <= n and 1 <= j and j <= i) {
        g[i][j] += v;
    }
}
void update(int n, int a, int b, int x, int v = 1) {
    add(n, a, b, v);
    add(n, a, b + 1, -v);
    add(n, a + x + 1, b, -v);
    add(n, a + x + 1, b + x + 2, v);
    add(n, a + x + 2, b + 1, v);
    add(n, a + x + 2, b + x + 2, -v);
}
void sum(int n, int si, int sj, int di, int dj) {
    for(int i = si; i <= n; i++) {
        for(int j = sj; j <= i; j++) {
            g[i][j] += g[i-di][j-dj];
        }
    }
}
void resolve(int n) {
    sum(n, 1, 2, 0, 1);
    sum(n, 2, 1, 1, 0);
    sum(n, 2, 2, 1, 1);
}
template <typename Function>
void proc(int n, const Function& f) {
#ifdef DEBUG
    using actual_type = typename callable_traits<Function>::function_type;
    using expected_type = typename callable_traits<void(int, int)>::function_type;
    static_assert(is_same<actual_type, expected_type>::value, "proc 'f' must be void(int, int)");
#endif
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            f(i, j);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    memset(g, 0, sizeof g);
    for(int i = 0; i < m; i++) {
        int a, b, x;
        cin >> a >> b >> x;
        update(n, a, b, x);
    }
    resolve(n);
    int ans = 0;
    proc(n, [&](int i, int j) { ans += g[i][j] > 0; });
    cout << ans << endl;
    return 0;
}

