#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));
  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];
        } else {
          for (int y = 0; y < m; ++y) {
            long long k = ed[y].first, l = ed[y].second;
            if ((k, l) == (j, x) || (l, k) == (j, x)) {
              d[y] = true;
              break;
            }
          }
        }
      }
  long long cnt = 0;
  for (int i = 0; i < m; ++i)
    if (!d[i]) cnt++;
  cout << cnt;
}
