#include <bits/stdc++.h>
using namespace std;
int dist[110][110];
int dist_t[110][110];
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  for (int(i) = 0; (i) < (int)(M); (i)++) cin >> a[i] >> b[i] >> c[i];
  for (int(i) = 0; (i) < (int)(110); (i)++)
    for (int(j) = 0; (j) < (int)(110); (j)++) dist[i][j] = 1e9;
  for (int i = 1; i <= N; i++) dist[i][i] = 0;
  for (int(i) = 0; (i) < (int)(M); (i)++)
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  long long ans = 0;
  vector<pair<int, pair<int, int> > > v(M);
  for (int(i) = 0; (i) < (int)(M); (i)++)
    v[i] = make_pair(c[i], make_pair(a[i], b[i]));
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  set<pair<int, int> > unused;
  for (int(kai) = 0; (kai) < (int)(M); (kai)++) {
    for (int(i) = 0; (i) < (int)(110); (i)++)
      for (int(j) = 0; (j) < (int)(110); (j)++) dist_t[i][j] = 1e9;
    for (int i = 1; i <= N; i++) dist_t[i][i] = 0;
    for (int(i) = 0; (i) < (int)(M); (i)++) {
      int aa = v[i].second.first, bb = v[i].second.second;
      if (i != kai && unused.find(make_pair(aa, bb)) == unused.end()) {
        dist_t[aa][bb] = dist_t[bb][aa] = v[i].first;
      }
    }
    for (int k = 1; k <= N; k++) {
      for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
          dist_t[i][j] = min(dist_t[i][j], dist_t[i][k] + dist_t[k][j]);
        }
      }
    }
    bool flag = true;
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        if (dist[i][j] != dist_t[i][j]) flag = false;
      }
    }
    if (flag) {
      ans++;
      unused.insert(make_pair(v[kai].second.first, v[kai].second.second));
      unused.insert(make_pair(v[kai].second.second, v[kai].second.first));
    }
  }
  cout << ans << endl;
  return 0;
}
