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

const int maxn = 5005;

int n, m, res;
int f[maxn][maxn];

int main() {
    ///freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    while (m --) {
        int a, b, x; cin >> a >> b >> x;
        f[a][b] = max(f[a][b], x + 1);
    }
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= i; j ++) {
            f[i][j] = max(f[i][j], max(f[i - 1][j - 1], f[i - 1][j]) - 1);
            ///cout << f[i][j] << ' ';
            if(f[i][j]) res ++;
        }
        ///cout << endl;
    }
    cout << res << endl;
}