#include <bits/stdc++.h>
using namespace std;
int m[105][105];
int mn[105];
int dijflag[105];
void dijk(int start, int V) {
  for (int i = 0; i < 105; i++) mn[i] = 1000000000;
  for (int i = 0; i < 105; i++) dijflag[i] = 0;
  mn[start] = 0;
  for (;;) {
    int v = -1;
    for (int i = 0; i < V; i++) {
      if (dijflag[i] == 0) {
        if (v == -1) {
          v = i;
        } else {
          if (mn[i] < mn[v]) {
            v = i;
          }
        }
      }
    }
    if (v == -1) break;
    dijflag[v] = 1;
    for (int i = 0; i < V; i++) {
      if (mn[i] > mn[v] + m[v][i]) {
        mn[i] = mn[v] + m[v][i];
      }
    }
  }
}
int main() {
  long long n, q;
  cin >> n >> q;
  vector<pair<long long, pair<long long, long long> > > v;
  for (int i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    long long c;
    cin >> c;
    v.push_back(make_pair(c, make_pair(a, b)));
  }
  sort((v).begin(), (v).end());
  reverse((v).begin(), (v).end());
  long long ans = 0;
  for (long long i = (0); i < (v.size()); ++i) {
    long long a = v[i].first;
    long long b = v[i].second.first;
    long long c = v[i].second.second;
    for (long long j = (0); j < (n); ++j) {
      for (long long k = (0); k < (n); ++k) {
        m[j][k] = 1000000000;
      }
    }
    for (long long j = (0); j < (v.size()); ++j) {
      if (i == j) continue;
      long long a1 = v[j].first;
      long long b1 = v[j].second.first;
      long long c1 = v[j].second.second;
      m[c1][b1] = a1;
      m[b1][c1] = a1;
    }
    dijk(b, n);
    long long d = mn[c];
    if (a >= d) ans++;
  }
  cout << ans << endl;
  return 0;
}
