#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > a(n, vector<long long>(n, 1e9)),
      p(n, vector<long long>(n, -1));
  vector<pair<long long, long long> > ed(m);
  vector<bool> d(m, false);
  for (int i = 0; i < m; ++i) {
    long long fr, to, w;
    cin >> fr >> to >> w;
    fr--, to--;
    ed[i] = {fr, to};
    a[fr][to] = a[to][fr] = w;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int x = 0; x < n; ++x) {
        if (a[j][x] > a[j][i] + a[i][x]) {
          a[j][x] = a[j][i] + a[i][x];
          p[j][x] = i;
        }
      }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (p[i][j] != -1) {
        for (int x = 0; x < m; ++x) {
          long long k = ed[x].first, l = ed[x].second;
          if (k == i && l == p[i][j] || k == j && l == p[i][j]) d[x] = true;
          swap(k, l);
          if (k == i && l == p[i][j] || k == j && l == p[i][j]) d[x] = true;
        }
      } else {
        if (a[i][j] != 1e9) {
          for (int x = 0; x < m; ++x) {
            long long k = ed[x].first, l = ed[x].second;
            if (k == i && l == j || k == j && l == i) d[x] = true;
          }
        }
      }
    }
  long long cnt = 0;
  for (int i = 0; i < m; ++i) {
    if (!d[i]) cnt++;
  }
  cout << cnt;
}
