#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int m, n;
  cin >> n >> m;
  int a[n][n];
  memset(a, 0x3f, sizeof(a));
  for (int i = 0; i < n; i++) a[i][i] = 0;
  set<pair<int, int> > s;
  for (int i = 0, j, k, c; i < m; i++) {
    cin >> j >> k >> c, --j, --k;
    s.insert(make_pair(j, k));
    s.insert(make_pair(k, j));
    a[j][k] = c;
    a[k][j] = c;
  }
  vector<bool> v(n, false);
  for (int k = 0; k < n; k++) {
    int t1 = -1, t2 = -1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        long long int y = a[i][k] + a[k][j];
        if (y < a[i][j]) {
          t1 = i;
          t2 = j;
          auto it = s.find({t1, k});
          if (it != s.end()) s.erase(it);
          auto itt = s.find({k, t1});
          if (itt != s.end()) s.erase(itt);
          it = s.find({t2, k});
          if (it != s.end()) s.erase(it);
          itt = s.find({k, t2});
          if (itt != s.end()) s.erase(itt);
        }
      }
  }
  cout << s.size() / 2 << endl;
  return 0;
}
