#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  int n;
  cin >> n;
  int m;
  cin >> m;
  int a[100], b[100], c[100];
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  if (n == 2)
    ans = 0;
  else
    for (int x = 1; x <= m; x++) {
      for (int y = 1; x < y && y <= m; y++) {
        for (int z = 1; y < z && z <= m; z++) {
          set<int> S{a[x], a[y], a[z], b[x], b[y], b[z]};
          if (S.size() == 3) {
            if (c[x] > (c[y] + c[z]))
              ans++;
            else if (c[y] > (c[x] + c[z]))
              ans++;
            else if (c[z] > (c[x] + c[y]))
              ans++;
          }
        }
      }
    }
  cout << ans << endl;
  return 0;
}
