#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000001;
const long long INF = 1e16;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
  int n, m, i, j, k;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  for (i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    if (a[i] < b[i]) {
      swap(a[i], b[i]);
    }
  }
  vector<vector<vector<int> > > use(n, vector<vector<int> >(n, vector<int>()));
  vector<vector<int> > d(n, vector<int>(n, inf));
  for (i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  for (i = 0; i < m; i++) {
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
    use[a[i]][b[i]].push_back(i);
    use[b[i]][a[i]].push_back(i);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = j; k < n; k++) {
        if (d[j][k] > d[j][i] + d[i][k]) {
          d[j][k] = d[j][i] + d[i][k];
          use[j][k].clear();
          use[j][k] = use[j][i];
          use[j][k].insert(use[j][k].end(), use[i][k].begin(), use[i][k].end());
        } else if (d[j][k] == d[j][i] + d[i][k]) {
          use[j][k].insert(use[j][k].end(), use[j][i].begin(), use[j][i].end());
          use[j][k].insert(use[j][k].end(), use[i][k].begin(), use[i][k].end());
        }
      }
    }
  }
  vector<bool> use2(m, false);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      for (k = 0; k < use[i][j].size(); k++) {
        use2[use[i][j][k]] = true;
      }
    }
  }
  int cnt = 0;
  for (i = 0; i < m; i++) {
    if (!use2[i]) cnt++;
  }
  cout << cnt << endl;
}
